【问题标题】:views don't shows on design mode in Android StudioAndroid Studio 中的设计模式不显示视图
【发布时间】:2021-08-21 19:01:51
【问题描述】:

视图突然停止在 Android Studio 的设计模式下显示(包括“hello world”textView)。我没有更新任何东西或改变任何东西。 我尝试了以下解决方案:

  1. (换主题)This view is not constrained android studio. I can not see the button even if I use Infer Constraints
  2. 推断约束。
  3. (找不到链接)但标记为正确的答案说我的 SDK 已损坏 -> 更新它不起作用。 我怀疑 Gradle 是罪魁祸首,所以这里是应用程序的构建脚本(一个全新的项目):

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'
}

我的 android Studio 是版本:3.6.3。 有任何想法吗?提前谢谢你。

【问题讨论】:

    标签: android android-studio


    【解决方案1】:
    • 确保您使用的是最新的稳定版 Android Studio 和所有相关工具
    • 更新您的项目以使用最新版本的 Gradle 和一切
    • 文件 -> 使缓存无效并重新启动
    • 构建 -> 清理项目
    • 构建 -> 重建项目
    • 运行

    【讨论】:

    • 这是个好主意,但我想知道问题的确切原因。由于将更新作为解决方案并不能告诉我太多有关问题的信息。 PS:我记得自上次使用 AS 以来我唯一改变的就是当 AS 使用 3.6.3 时将 Gradle 更新到 6.4.1。所以我认为这确实是罪魁祸首。
    【解决方案2】:

    我通过更改我正在使用的 contraintLayout 实现的版本解决了这个问题。我添加到文件 build.gradle(:app):

        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-05
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 2021-09-09
      • 1970-01-01
      相关资源
      最近更新 更多