当前位置: 首页 > 面试题库 >

NoClassDefFoundError Landroid / arch / lifecycle / LifecycleDispatcher

姜兴业
2023-03-14
问题内容

我想尝试Google(https://developer.android.com/arch)的新生命周期资料,但打开应用时会崩溃。我要做的就是添加依赖项。还有其他人有这个问题吗?

日志:

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依赖项:

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'

问题答案:

您是否使用Proguard?如果是这样,请尝试将其关闭:

debug {
    minifyEnabled false
    useProguard false
}

或者,您可以将自定义规则添加到您的Proguard配置中:

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


 类似资料:
  • Angular 2应用程序遍历整个流程集,或者从应用程序的启动到结束都有一个生命周期。 下图显示了Angular 2应用程序生命周期中的整个过程。 以下是每个生命周期钩子的描述。 ngOnChanges - 当数据绑定属性的值更改时,将调用此方法。 ngOnInit - 只要在Angular首次显示数据绑定属性后初始化指令/组件,就会调用此方法。 ngDoCheck - 用于检测并对Angular

  • caution This section is a work in progress. Lifecycle APIs are shared by Themes and Plugins. validateOptions({options, validate}) Return validated and normalized options for the plugin. This method is

  • Android、iOS 和最新的 Windows 系统可以随时自主地停止后台进程,及时释放系统资源。也就是说,网页可能随时被系统丢弃掉。以前的浏览器 API 完全没有考虑到这种情况,导致开发者根本没有办法监听到系统丢弃页面。 为了解决这个问题,W3C 新制定了一个 Page Lifecycle API,统一了网页从诞生到卸载的行为模式,并且定义了新的事件,允许开发者响应网页状态的各种转换。 有了这

  • Documentation User documentation can be found on the OLM website. Overview This project is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, calle

  • SRS最关键是Simple,最简单的方案就是最佳方案;这个文章记录了SRS关键的Simple方案,也就是50%代码完成200%功能,100%代码完成400%功能的要点。 State Threads ST带来的问题简化,在一个状态空间时至少一个数量级;多个状态空间时就是百个数量级,譬如edge回源,http-flv和hstrs。在网络服务器中st的思路是与众不同,也是很巧妙的思路。 SRS是单进程使

  • GNU arch is a distributed revision control system that is part of the GNU Project and licensed under the GNU General Public License. It is used to keep track of the changes made to a source tree and t