'Android studio can't see the design?

I have been doing it in Android studio for a few days but I have never had such a problem :(

Background blank only text showing androidx.constraintlayout....ConstraintLayout

XML file

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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">
</androidx.constraintlayout.widget.ConstraintLayout>

Gradle file

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

enter image description here

dependencies {
    classpath "com.android.tools.build:gradle:7.0.4"

    // NOTE: Do not place your application dependencies here; they 
    belong
    // in the individual module build.gradle files
}


Solution 1:[1]

Update your Constraintlayout dependency in your app level build.gradle and check:

implementation 'androidx.constraintlayout:constraintlayout:2.1.3'

Solution 2:[2]

I think it's related to the Gradle script file version issue just see your dependencies and change if it is outdated.. maybe this can help?

dependencies {
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
}

and sync it !!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Charlie