Chris C.
Chris C.

Reputation: 80

Android Studio 3.1.4 Design Preview Not Rendering Material Design Elements

I'm using Android Studio 3.1.4. In order to use the latest material design library, I updated the compile and target SDK versions to 28. Right now, I'm using some TextInputLayouts and TextInputEditTexts in a basic linear layout, and the design preview doesn't render them properly. It also doesn't render any elements that follow it properly. I'm getting the following errors in the Design Preview:

java.lang.IllegalArgumentException: Underflow in restoreToCount - more restores than saves at android.graphics.Canvas.restoreToCount(Canvas.java:604) at android.support.design.widget.CutoutDrawable.postDraw(CutoutDrawable.java:113) at android.support.design.widget.CutoutDrawable.draw(CutoutDrawable.java:87) at android.support.design.widget.TextInputLayout.draw(TextInputLayout.java:1575)

Here's what the preview actually looks like - Not particularly helpful to design in:

Improper Rendering of Material Design Elements

I've hunted around for a fix for this and can't seem to find anything that's useful for this current version of Android Studio or SDK 28. Here's the app build.gradle file:

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

Is it possible there's an issue with one of the release candidate libraries?

Upvotes: 2

Views: 521

Answers (1)

Ben
Ben

Reputation: 21

In order to make this work I changed:

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

I saw this online and it is working according to my tests, the only downside is that you would have to make this change on every project.

Upvotes: 2

Related Questions