Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

binary xml file line #1: error inflating class <unknown> What should I do now?

Tags:

java

android

The Preview of android:text="Hello World" is not showing. What should I do now to solve this?

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World"
        android:textColor="red"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout> 
like image 369
Md. Al-Amin Avatar asked Jan 24 '26 20:01

Md. Al-Amin


1 Answers

1.st replace in your activity_main.xml layout android.support.constraint.ConstraintLayout with androidx.constraintlayout.widget.ConstraintLayout

2.nd go into app.gradle and add to dependencies implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

enter image description here

and press Sync Now

like image 180
sausagerus Avatar answered Jan 27 '26 12:01

sausagerus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!