布局预览在Android Studio 3.4.1中不起作用

时间:2019-06-06 12:18:43

标签: android android-studio android-layout

最近我的android studio不在预览中显示设计

尝试过:

  • 重建的应用程序
  • 使缓存无效并重新启动
  • 也重新启动系统

我在日志中遇到了异常

java.lang.IllegalArgumentException: java.lang.ClassCastException@7f378372
    at sun.reflect.GeneratedMethodAccessor513.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
    at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
    at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
    at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
    at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
    at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
    at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
    at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
    at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
    at android.animation.StateListAnimator.start(StateListAnimator.java:188)
    at android.animation.StateListAnimator.setState(StateListAnimator.java:181)
    at android.view.View.drawableStateChanged(View.java:21105)
    at android.view.ViewGroup.drawableStateChanged(ViewGroup.java:7101)
    at com.google.android.material.appbar.AppBarLayout.drawableStateChanged(AppBarLayout.java:393)
    at android.view.View.refreshDrawableState(View.java:21160)
    at android.view.View.dispatchAttachedToWindow(View.java:18379)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:335)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:391)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:195)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:540)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:666)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

注意:之前运行良好

等级依赖为

dependencies { configuration ->
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    androidSupport(configuration)
    customViews(configuration)
    def parceler_verion = '1.1.12'
    implementation 'com.batch.android:batch-sdk:1.13.0'
    implementation "org.parceler:parceler-api:$parceler_verion"
    annotationProcessor "org.parceler:parceler:$parceler_verion"
    implementation 'org.apache.commons:commons-text:1.3'
    implementation 'com.instabug.library:instabug:8.3.0'
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    test(configuration)
    network(configuration)
    googleAndFirebase(configuration)
    rxJava(configuration)
    driveQuantSDK(configuration)
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
}

private static void test(configuration) {
    configuration.testImplementation 'junit:junit:4.12'
    configuration.androidTestImplementation 'androidx.test:runner:1.1.0'
    configuration.androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    configuration.implementation 'androidx.test.espresso:espresso-idling-resource:3.1.0'
}

private static void androidSupport(configuration) {

    configuration.implementation 'androidx.multidex:multidex:2.0.0'
    configuration.implementation 'androidx.appcompat:appcompat:1.0.0'
    configuration.implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    configuration.implementation 'com.google.android.material:material:1.1.0-alpha06'
    configuration.implementation 'androidx.cardview:cardview:1.0.0'
    configuration.implementation 'androidx.recyclerview:recyclerview:1.0.0'
    configuration.implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    configuration.implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    configuration.implementation 'androidx.viewpager:viewpager:1.0.0'
}

private static void customViews(configuration) {
    configuration.implementation 'de.hdodenhof:circleimageview:3.0.0'
    configuration.implementation 'com.romandanylyk:pageindicatorview:1.0.3'
    configuration.implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
    configuration.implementation 'nl.dionsegijn:konfetti:1.1.2'
    configuration.implementation 'com.github.chrisbanes:PhotoView:2.3.0'
    configuration.implementation 'com.github.esafirm.android-image-picker:imagepicker:2.0.0'
    configuration.implementation 'com.github.esafirm.android-image-picker:rximagepicker:2.0.0'
    configuration.implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
}

private static void network(configuration) {
    def retrofit_version = '2.4.0'
    def glide_version = '4.8.0'
    def okhttp_logging_version = '3.10.0'
    def stetho_version = '1.5.0'

    configuration.implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_logging_version"
    configuration.implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    configuration.implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    configuration.implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
    configuration.implementation "com.github.bumptech.glide:glide:$glide_version"
    configuration.implementation "com.facebook.stetho:stetho:$stetho_version"
    configuration.implementation "com.facebook.stetho:stetho-okhttp3:$stetho_version"


}

private static void googleAndFirebase(configuration) {
    //gcm
    configuration.implementation 'com.google.android.gms:play-services-gcm:16.0.0'

    //Firebase libs
//    configuration.implementation 'com.google.firebase:firebase-core:16.0.7'
    configuration.implementation 'com.google.firebase:firebase-auth:16.1.0'
    configuration.implementation 'com.google.firebase:firebase-database:16.0.6'
    configuration.implementation 'com.google.firebase:firebase-messaging:17.3.4'

    //lib for map
    configuration.implementation 'com.google.android.gms:play-services-maps:16.0.0'
    configuration.implementation 'com.google.android.gms:play-services-location:16.0.0'

    //google analytics
    configuration.implementation 'com.google.android.gms:play-services-analytics:16.0.6'

    //map utils
    configuration.implementation 'com.google.maps.android:android-maps-utils:0.5'
}

private static void rxJava(configuration) {
    def rxjava_version = '2.1.12'
    def rxjava_android_version = '2.0.2'
    configuration.implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
    configuration.implementation "io.reactivex.rxjava2:rxandroid:$rxjava_android_version"
}

2 个答案:

答案 0 :(得分:1)

在预览内部更改Theme

enter image description here

那可以解决问题

答案 1 :(得分:0)

'com.google.android.material:material:1.1.0-alpha06'将其降级为'com.google.android.material:material:1.1.0-alpha04'