【问题标题】:Android Studio 3.1.4 Design Preview Not Rendering Material Design ElementsAndroid Studio 3.1.4 设计预览不渲染材料设计元素
【发布时间】:2019-01-27 06:53:55
【问题描述】:

我使用的是 Android Studio 3.1.4。为了使用最新的材料设计库,我将编译和目标 SDK 版本更新为 28。现在,我在基本线性布局中使用一些 TextInputLayouts 和 TextInputEditTexts,并且设计预览无法正确呈现它们。它也不会渲染任何正确跟随它的元素。我在设计预览中遇到以下错误:

java.lang.IllegalArgumentException:restoreToCount 中的下溢 - 恢复次数多于保存次数 在 android.graphics.Canvas.restoreToCount(Canvas.java:604) 在 android.support.design.widget.CutoutDrawable.postDraw(CutoutDrawable.java:113) 在 android.support.design.widget.CutoutDrawable.draw(CutoutDrawable.java:87) 在 android.support.design.widget.TextInputLayout.draw(TextInputLayout.java:1575)

这是预览的实际外观 - 对设计没有特别帮助:

我一直在寻找解决此问题的方法,但似乎找不到任何对当前版本的 Android Studio 或 SDK 28 有用的东西。这是应用程序 build.gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.the.appname.here"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support:exifinterface:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:support-v4:28.0.0-rc01'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
    implementation 'com.android.support:cardview-v7:28.0.0-rc01'
    implementation 'com.android.support:design:28.0.0-rc01'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation ('com.twitter.sdk.android:twitter:3.3.0@aar') {
        transitive = true
    }
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}

apply plugin: 'com.google.gms.google-services'`

其中一个发布候选库是否可能存在问题?

【问题讨论】:

  • 你试过重建你的项目吗?
  • @Qasim 我有 - 清理并重建以及使缓存无效并重新启动。
  • 你找到解决办法了吗?
  • 很遗憾没有。虽然没有证据,但我相对确定这是使用候选版本库而不是完整的黄金版本。
  • 作为一个更新,这些库中的大部分已经转移到 rc02。我已经对其进行了测试,但问题仍然存在。

标签: android android-studio android-9.0-pie android-studio-3.1.4


【解决方案1】:

为了完成这项工作,我进行了更改:

implementation 'com.android.support:appcompat-v7:28.0.0-rc01' (rc01)

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1' (alpha1)

我在网上看到了这个,根据我的测试它正在工作,唯一的缺点是你必须在每个项目上进行这个更改。

【讨论】:

  • 嗨,Ben,你有“在线”资源的来源吗?我很好奇为什么会这样:)
  • 嘿,本。这对我不起作用。为澄清起见 - 您是否对所有使用 28.0.0 的库进行了更改?
猜你喜欢
  • 1970-01-01
  • 2016-07-06
  • 2015-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-09
  • 2019-03-10
  • 2023-03-25
相关资源
最近更新 更多