java.lang.NoClassDefFoundError:无法解决以下问题:Lorg/apache/commons/logging/LogFactory [英] java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory
问题描述
类似的问题已经需要提出了.但是由于Android平台兼容性的变化,该版本似乎比以前的版本更复杂.
Similar questions have need asked already. But this one seems to be more complicated than previous ones because of changes in compatibility of Android Platforms.
这是我的Pixel和Pixel2错误日志,它们已注册Android Beta程序
Here is my error log from Pixel and Pixel2 which are signed up for Android Beta Program
08-16 13:20:53.146 9630-9630/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.project.android.dev, PID: 9630
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory;
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.commons.logging.LogFactory" on path: DexPathList[[zip file "/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk"],nativeLibraryDirectories=[/data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/lib/arm64, /data/app/me.project.android.dev-0SPRJnc8-4voauRU7Y20zQ==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.amazonaws.util.VersionInfoUtils.<clinit>(VersionInfoUtils.java:41)
at com.amazonaws.util.VersionInfoUtils.c(VersionInfoUtils.java:77)
at com.amazonaws.ClientConfiguration.<clinit>(ClientConfiguration.java:43)
//project specific class reference removed
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
在运行Android 7.0及更低版本的设备上运行时,使用相同的代码即可.
Same code when ran on Devices running Android 7.0 and below, it works perfectly fine.
我也尝试向项目添加依赖项
I tried adding dependency to my project too
implementation "commons-logging:commons-logging:1.2"
添加此依赖项可使该应用程序在Pixel和Pixel中运行,但随后在所有其他设备中崩溃,并显示异常
Adding this dependency makes the app work in Pixel and Pixel but then it crashes in all other devices with Exception saying
org.apache.commons.logging.impl.LogFactoryImpl does not extend or implement org.apache.commons.logging.LogFactory
我已经尝试在ProGuard中进行所有更改.这是我的proguard配置
I tried doing all the changes in ProGuard already. Here is my proguard configuration
-keep class org.apache.commons.logging.impl.LogFactoryImpl
-keep class org.apache.commons.logging.LogFactory
-keepnames class org.apache.commons.logging.impl.* {*;}
-keepnames class org.apache.commons.logging.*
-keepclassmembers class org.apache.commons.logging.impl.* {*;}
-keepclassmembers class org.apache.commons.logging.*
-keepnames interface org.apache.commons.logging.impl.* {*;}
-keepnames interface org.apache.commons.logging.*
仍然导致崩溃.
此问题与Amazon AWS开发工具包相关- https://github.com/aws/aws-sdk-android/issues/476
This issue is related to Amazon AWS SDK - https://github.com/aws/aws-sdk-android/issues/476
在AWS更新其SDK以解决此问题之前,是否有任何解决方法?
Is there any workaround till AWS updates their SDK to fix this issue?
推荐答案
This is an AWS SDK bug that appears to be solved in version 2.6.30 of the SDK:
修复了一个使用Apache Commons Logging获取记录器的错误 Android 9.0(Pie/API级别28)启动时崩溃.参见拉#521.现在, 如果将Apache Commons Logging添加为 依赖项,否则将使用android.util.Log.
Fixed a bug where getting a logger using Apache Commons Logging would crash starting Android 9.0 (Pie / API Level 28). See pull #521. Now, Apache Commons Logging would be used if it's being added as a dependency, otherwise android.util.Log will be used.
这篇关于java.lang.NoClassDefFoundError:无法解决以下问题:Lorg/apache/commons/logging/LogFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!