已经需要提出类似的问题。但是由于Android平台兼容性的变化,这个似乎比以前的更复杂。
这是我注册 Android Beta Program 的 Pixel 和 Pixel2 的错误日志
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 及更低版本的设备上运行相同的代码时,它工作得非常好。
我也尝试向我的项目添加依赖项
implementation "commons-logging:commons-logging:1.2"
添加此依赖项使应用程序在 Pixel 和 Pixel 中运行,但随后它在所有其他设备中崩溃并显示异常
org.apache.commons.logging.impl.LogFactoryImpl does not extend or implement org.apache.commons.logging.LogFactory
我已经尝试在 ProGuard 中进行所有更改。这是我的proguard配置
-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
在 AWS 更新其 SDK 以解决此问题之前,是否有任何解决方法?