【问题标题】:Grey screen showing up on layout xml after switching to Androidx切换到 Androidx 后,布局 xml 上出现灰屏
【发布时间】:2019-11-10 00:52:11
【问题描述】:

切换到 Androidx 后,当我返回到我的活动 xml 时,它只显示带有“androidx.constraintlayout....ConstraintLayout”的灰屏

我尝试弄乱 gradle 并切换受约束的布局版本,但没有运气。

请有人帮我解决这个问题,因为我不知道该怎么做。

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.hammad.firstapplication"
    minSdkVersion 22
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'


}

【问题讨论】:

  • 分享你的xml代码。
  • 关闭Android Studio再打开
  • schemas.android.com/apk/res/android" xmlns:tools="schemas.android.com/tools " android:layout_width="match_parent" android:layout_height="match_parent"/> @Ashishsingh
  • @HB 我已经尝试过了,但没有运气

标签: android android-constraintlayout androidx


【解决方案1】:

在 Android Studio 中按 Build>>Rebuild Project

【讨论】:

    【解决方案2】:

    尝试在 Android Studio 中点击箭头所示的“Sync project with Gradle files”按钮:

    【讨论】:

    • Android Studio 中的“同步项目与 Gradle 文件”按钮
    • @Cœur 在它仅作为图片链接发布之前,因此我将其标记为仅链接答案。
    【解决方案3】:

    尝试降低您的约束布局版本

    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'
    

    使用1.1.2 或1.1.1 代替2.0.0-alpha4

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多