8

当我从 Eclipse 中“作为 Android 应用程序运行”时,我的应用程序运行良好。在过去,我也成功地导出了应用程序的签名版本。

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

原因:aaaab:选择的 LogFactory 实现没有扩展 LogFactory。请检查您的配置。(由 java.lang.ClassCastException 引起:应用程序已指定应使用自定义 LogFactory 实现,但类 'org.apache.commons.logging.impl.LogFactoryImpl' 无法转换为 'aaaac'。请检查自定义实现。可以在@http ://commons.apache.org/logging/troubleshooting.html找到帮助。)。

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

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

apache.org 文档说:

只有在运行时动态加载的实现类可以转换为加载它的 LogFactory 类时,才能使用自定义 LogFactory 实现。有几种方法会导致此转换失败。最明显的是源代码实际上可能没有扩展 LogFactory。源可能是兼容的,但如果编译源的 LogFactory 类不是二进制兼容的,那么转换也将失败。

还有另一种更不寻常的方式会导致这种转换失败:即使二进制文件兼容,在运行时加载的实现类也可能链接到 LogFactory 类的不同实例。有关详细信息,请参阅技术指南。

在使用自定义 LogFactory 实现的容器中可能会遇到这种情况。该实现通常与 JCL 一起在共享的高级类加载器中提供。当应用程序类加载器包含 LogFactory 时,将从更高级别的类加载器加载实现。实现类将链接到由更高级别的类加载器加载的 LogFactory 类。即使 LogFactory 实现是二进制兼容的,因为它们是由不同的类加载器加载的,所以两个 LogFactory 类实例不相等,因此强制转换必须失败。

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

有多种方法可以解决此问题。哪种修复是正确的取决于具体情况。

如果您乐于为应用程序使用另一个类加载策略,请选择一个类加载策略,以确保从包含自定义实现的共享类加载器加载 LogFactory。

如果要绕过容器适配机制,则在容器启动时将相应的系统属性设置为默认值:

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

如果您想继续使用默认的容器机制,那么: • 使用最新版本查找并替换容器使用的 commons-logging 实现 • 将应用程序中的 commons-logging jar 替换为 commons-logging-adapters jar。这将确保应用程序类加载器在加载 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
4

1 回答 1

2

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

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

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

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

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

还检查:如何从 Proguard(Android 项目)的混淆中排除外部 .jar?

于 2013-09-22T06:19:13.067 回答