gpt4 book ai didi

android - 使用 apache.commons.logging 类失败的已签名导出 Android 应用程序无法转换为 'a.a.a.a.c'

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:16:19 30 4
gpt4 key购买 nike

当我从 Eclipse 中“作为 Android 应用程序运行”时,我的应用程序运行完美。过去,我还成功导出了该应用程序的签名版本。

现在,应用程序的导出版本突然立即崩溃。关键信息似乎是

Caused by: a.a.a.a.b: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'a.a.a.a.c'. Please check the custom implementation. Help can be found @ http://commons.apache.org/logging/troubleshooting.html.).

这是 Proguard 设置。我错过了什么吗?

-dontwarn org.apache.** 
-dontwarn org.apache.commons.logging.**
-ignorewarnings
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers

apache.org doc说:

A custom LogFactory implementation can only be used if the implementation class loaded dynamically at runtime can be cast to the LogFactory class that loaded it. There are several ways in which this cast can fail. The most obvious is that the source code may not actually extend LogFactory. The source may be compatible but if the LogFactory class against which the source is compiled is not binary compatible then the cast will also fail.

There is also another more unusual way in which this cast can fail: even when the binary is compatible, the implementation class loaded at runtime may be linked to a different instance of the LogFactory class. For more information, see the tech guide.

This situation may be encountered in containers which use a custom LogFactory implementation. The implementation will typically be provided in a shared, high level classloader together with JCL. When an application classloader contains LogFactory, the implementation will be loaded from that higher level classloader. The implementation class will be linked to the LogFactory class loaded by the higher level classloader. Even if the LogFactory implementations are binary compatible, since they are loaded by different classloaders the two LogFactory Class instances are not equal and so the cast must fail.

他们继续说潜在的修复包括:

There are various ways to fix this problem. Which fix is right depends on the circumstances.

If you are happy using another classloading policy for the application, select a classloading policy which ensures that LogFactory will be loaded from the shared classloader containing the custom implementation.

If you want to bypass the container adaption mechanism then set the appropriate system property to the default value when the container is started:

-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl

If you want to continue to use the default container mechanism then: • Find and replace the commons-logging implementation used by the container with the most modern release • Replace the commons-logging jar in the application with the commons-logging-adapters jar. This will ensure that application classloader will delegate to it's parent when loading LogFactory.

我认为“-Dorg.apache.commons......”命令会进入 proguard-project.txt 文件,但这导致应用程序甚至无法构建。所以最重要的是,我不明白 apache 想说什么,我希望你们中的一些有经验的人可以提供一些清晰度/指导。

这是堆栈跟踪:

07-22 02:49:32.109: E/AndroidRuntime(13589): FATAL EXCEPTION: AsyncTask #1
07-22 02:49:32.109: E/AndroidRuntime(13589): java.lang.RuntimeException: An error occured while executing doInBackground()
07-22 02:49:32.109: E/AndroidRuntime(13589): at android.os.AsyncTask$3.done(AsyncTask.java:299)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-22 02:49:32.109: E/AndroidRuntime(13589): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.lang.Thread.run(Thread.java:856)
07-22 02:49:32.109: E/AndroidRuntime(13589): Caused by: a.a.a.a.b: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'a.a.a.a.c'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.a.a.c.a(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.a.a.e.run(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.security.AccessController.doPrivileged(AccessController.java:45)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.a.a.c.a(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.a.a.c.h(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.a.a.c.c(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.b.f.b.b.<init>(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at a.a.b.f.b.g.<init>(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at toolbox.e.a(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at toolbox.e.doInBackground(Unknown Source)
07-22 02:49:32.109: E/AndroidRuntime(13589): at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-22 02:49:32.109: E/AndroidRuntime(13589): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-22 02:49:32.109: E/AndroidRuntime(13589): ... 5 more
07-22 02:49:32.109: E/AndroidRuntime(13589): Caused by: java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'a.a.a.a.c'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.
07-22 02:49:32.109: E/AndroidRuntime(13589): ... 17 more
07-22 02:49:32.169: E/(13589): <s3dReadConfigFile:75>: Can't open file for reading
07-22 02:49:32.169: E/(13589): <s3dReadConfigFile:75>: Can't open file for reading
07-22 02:49:32.359: E/SMD(176): DCD ON
07-22 02:49:33.090: E/MP-Decision(1545): DOWN Ld:36 Ns:1.100000 Ts:190 rq:0.400000 seq:196.000000
07-22 02:49:34.191: E/MP-Decision(1545): UP Ld:79 Nw:1.990000 Tw:140 rq:1.700000 seq:147.000000
07-22 02:49:35.353: E/SMD(176): DCD ON
07-22 02:49:36.734: E/Sensors(713): accelHandler -0.001198 -0.114961 10.077044
07-22 02:49:36.944: E/MP-Decision(1545): DOWN Ld:27 Ns:1.100000 Ts:190 rq:0.300000 seq:196.000000
07-22 02:49:38.356: E/SMD(176): DCD ON
07-22 02:49:38.977: E/MP-Decision(1545): UP Ld:36 Nw:1.990000 Tw:140 rq:2.800000 seq:147.000000
07-22 02:49:39.317: E/WifiP2pStateTracker(713): getNetworkInfo : NetworkInfo: type: WIFI_P2P[], state: DISCONNECTED/DISCONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
07-22 02:49:39.447: E/ActivityThread(11387): Service com.facebook.katana.platform.PlatformService has leaked ServiceConnection com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$BlueServiceConnection@4235a770 that was originally bound here
07-22 02:49:39.447: E/ActivityThread(11387): android.app.ServiceConnectionLeaked: Service com.facebook.katana.platform.PlatformService has leaked ServiceConnection com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$BlueServiceConnection@4235a770 that was originally bound here
07-22 02:49:39.447: E/ActivityThread(11387): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:965)
07-22 02:49:39.447: E/ActivityThread(11387): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:859)
07-22 02:49:39.447: E/ActivityThread(11387): at android.app.ContextImpl.bindService(ContextImpl.java:1308)
07-22 02:49:39.447: E/ActivityThread(11387): at android.app.ContextImpl.bindService(ContextImpl.java:1300)
07-22 02:49:39.447: E/ActivityThread(11387): at android.content.ContextWrapper.bindService(ContextWrapper.java:401)
07-22 02:49:39.447: E/ActivityThread(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.f(DefaultBlueServiceOperationFactory.java:426)
07-22 02:49:39.447: E/ActivityThread(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.a(DefaultBlueServiceOperationFactory.java:384)
07-22 02:49:39.447: E/ActivityThread(11387): at com.facebook.katana.platform.PlatformService.b(PlatformService.java:184)
07-22 02:49:39.447: E/ActivityThread(11387): at com.facebook.katana.platform.PlatformService.a(PlatformService.java:36)
07-22 02:49:39.447: E/ActivityThread(11387): at com.facebook.katana.platform.PlatformService$MessageHandler.handleMessage(PlatformService.java:71)
07-22 02:49:39.447: E/ActivityThread(11387): at android.os.Handler.dispatchMessage(Handler.java:99)
07-22 02:49:39.447: E/ActivityThread(11387): at android.os.Looper.loop(Looper.java:137)
07-22 02:49:39.447: E/ActivityThread(11387): at android.app.ActivityThread.main(ActivityThread.java:4918)
07-22 02:49:39.447: E/ActivityThread(11387): at java.lang.reflect.Method.invokeNative(Native Method)
07-22 02:49:39.447: E/ActivityThread(11387): at java.lang.reflect.Method.invoke(Method.java:511)
07-22 02:49:39.447: E/ActivityThread(11387): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
07-22 02:49:39.447: E/ActivityThread(11387): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
07-22 02:49:39.447: E/ActivityThread(11387): at dalvik.system.NativeStart.main(Native Method)
07-22 02:49:39.517: E/Launcher(24512): Error finding setting, default accessibility to not found: accessibility_enabled
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): com.facebook.debug.log.TerribleFailure: Exception unbinding: OperationType{Operation Name=platform_authorize_app, forRemote=false}
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.debug.log.FbLogImpl.f(FbLogImpl.java:147)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.debug.log.FbLogImpl.a(FbLogImpl.java:118)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.debug.log.BLog.a(BLog.java:790)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.e(DefaultBlueServiceOperationFactory.java:362)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.d(DefaultBlueServiceOperationFactory.java:103)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$1.b(DefaultBlueServiceOperationFactory.java:261)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.common.dispose.AbstractListenableDisposable.a(AbstractListenableDisposable.java:34)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.c(DefaultBlueServiceOperationFactory.java:288)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.a(DefaultBlueServiceOperationFactory.java:603)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.b(DefaultBlueServiceOperationFactory.java:561)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.c(DefaultBlueServiceOperationFactory.java:103)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$4.run(DefaultBlueServiceOperationFactory.java:537)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.os.Handler.handleCallback(Handler.java:615)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.os.Handler.dispatchMessage(Handler.java:92)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.os.Looper.loop(Looper.java:137)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.app.ActivityThread.main(ActivityThread.java:4918)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at java.lang.reflect.Method.invokeNative(Native Method)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at java.lang.reflect.Method.invoke(Method.java:511)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at dalvik.system.NativeStart.main(Native Method)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): Caused by: java.lang.IllegalArgumentException: Service not registered: com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$BlueServiceConnection@4235a770
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:917)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.app.ContextImpl.unbindService(ContextImpl.java:1338)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at android.content.ContextWrapper.unbindService(ContextWrapper.java:412)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.e(DefaultBlueServiceOperationFactory.java:357)
07-22 02:49:39.667: A/fb4a(:<default>):BlueServiceOperationFactory$Operation(11387): ... 17 more

最佳答案

当我项目中的外部 JAR 使用 org.apache.commons.logging.impl.LogFactoryImpl 时,我遇到了同样的问题。

值得注意的是,JAR 本身可能已经编译了来自不同包的类,所有类都驻留在 JAR 文件中。只需打开 JAR 并查看。

在 proguard 设置文件中,您应该声明 jar 中的所有前缀,例如:

-keep org.apache.** { *; }
-keep com.somejar.** { *; }

另一种选择是告诉混淆器完全忽略整个 JAR。

同时检查:How can I exclude external .jar from obfuscation by Proguard (Android project)?

关于android - 使用 apache.commons.logging 类失败的已签名导出 Android 应用程序无法转换为 'a.a.a.a.c',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17784927/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com