0

Views stopped showing on Design Mode in Android Studio out of the blue (including the "hello world" textView). I haven't updated anything or changed anything. I tried the following solutions:

  1. (changing the theme) This view is not constrained android studio. I can not see the button even if I use Infer Constraints
  2. inferring constraints.
  3. (can't find the link) but the answer marked as correct said my SDK is corrupt -> updating it didn't work. I'm suspecting Gradle is the culprit somehow, so here's the app's build script (a brand new project):

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.cc.take6"
        minSdkVersion 28
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

my android Studio is version: 3.6.3. Any ideas? thank you in advance.

2 Answers2

0
  • Make sure you are using the latest stable version of Android Studio and all related tools
  • Update your project to use latest version of Gradle and everything
  • File -> Invalidate Caches and Restart
  • Build -> Clean Project
  • Build -> Rebuild Project
  • Run
Harry
  • 323
  • 3
  • 10
  • that's a good idea, but I'd like to know the exact cause of the problem. As resorting to updates as a solution doesn't tell me much about the problem. PS: I remembered that the only thing I changed since last time I used AS, was updating Gradle to 6.4.1 when AS uses 3.6.3. So I'm thinking it's the culprit indeed. –  Aug 23 '21 at 18:10
0

I fixed the problem by changing the version of contraintLayout implementation that I was using. I added to the file build.gradle(:app):

    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'