Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

java - NoClassDefFoundError Landroid/arch/lifecycle/LifecycleDispatcher

I want to try out the new lifecycle stuff from google (https://developer.android.com/arch) but getting a crash on app open. All I have done is add the dependencies. Is anyone else having this problem?

LOG:

FATAL EXCEPTION: main
Process: com.duetandroid.app.mock, PID: 17857
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/arch/lifecycle/LifecycleDispatcher;
at android.arch.lifecycle.LifecycleRuntimeTrojanProvider.onCreate(LifecycleRuntimeTrojanProvider.java:35)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
at android.app.ActivityThread.installProvider(ActivityThread.java:5853)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleDispatcher" on path: DexPathList[[zip file "/data/app/com.duetandroid.app.mock-1/base.apk"],nativeLibraryDirectories=[/data/app/com.duetandroid.app.mock-1/lib/x86, /data/app/com.duetandroid.app.mock-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.arch.lifecycle.LifecycleRuntimeTrojanProvider.onCreate(LifecycleRuntimeTrojanProvider.java:35)?
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)?
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)?
at android.app.ActivityThread.installProvider(ActivityThread.java:5853)?
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5445)?
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5384)?
at android.app.ActivityThread.-wrap2(ActivityThread.java)?
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)?
at android.os.Handler.dispatchMessage(Handler.java:102)?
at android.os.Looper.loop(Looper.java:154)?
at android.app.ActivityThread.main(ActivityThread.java:6119)?
at java.lang.reflect.Method.invoke(Native Method)?
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)?
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

build.gradle dependencies:

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:preference-v14:25.3.1'
compile 'com.google.guava:guava:20.0'
compile 'com.google.code.findbugs:annotations:3.0.1'
compile 'com.sylversky.fontreplacer:fontreplacer:1.0'
compile 'com.github.barteksc:android-pdf-viewer:2.5.1'
compile 'commons-io:commons-io:2.5'
compile 'com.github.angads25:filepicker:1.1.0'
compile 'com.google.firebase:firebase-core:10.2.6'
compile 'com.google.firebase:firebase-crash:10.2.6'
compile 'android.arch.lifecycle:runtime:1.0.0-alpha1'
compile 'android.arch.lifecycle:extensions:1.0.0-alpha1'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0-alpha1'
compile 'android.arch.persistence.room:runtime:1.0.0-alpha1'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0-alpha1'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Do you use Proguard? If so, try to turn it off:

debug {
    minifyEnabled false
    useProguard false
}

Or you can add custom rule to your Proguard config:

-keep class android.arch.** { *; }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...