title: Signed Exported Android App failing with apache.commons.logging class cannot be converted to 'a.a.a.a.c'
body: <p>My app runs perfectly when I "Run as Android Application" from Eclipse.  In the past I've also successfully exported a signed version of the app.  </p>
  
  <p>Now, suddenly the exported version of the app crashes immediately.  The key message seems to be </p>
  
  <blockquote>
    <p>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 @ <a href="http://commons.apache.org/logging/troubleshooting.html" rel="noreferrer">http://commons.apache.org/logging/troubleshooting.html</a>.).</p>
  </blockquote>
  
  <p>Here are the Proguard settings.  Am I missing something?  </p>
  
  <pre><code>-dontwarn org.apache.** 
  -dontwarn org.apache.commons.logging.**
  -ignorewarnings 
  -dontusemixedcaseclassnames
  -dontskipnonpubliclibraryclasses
  -dontskipnonpubliclibraryclassmembers
  </code></pre>
  
  <p>The <a href="http://commons.apache.org/logging/troubleshooting.html" rel="noreferrer">apache.org doc</a> says: </p>
  
  <blockquote>
    <p>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. </p>
    
    <p>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. </p>
    
    <p>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. </p>
  </blockquote>
  
  <p>They go on to say potential Fixes include:</p>
  
  <blockquote>
    <p>There are various ways to fix this problem. Which fix is right depends on the circumstances. </p>
    
    <p>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. </p>
    
    <p>If you want to bypass the container adaption mechanism then set the appropriate system property to the default value when the container is started: </p>
    
    <p>-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl</p>
    
    <p>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. </p>
  </blockquote>
  
  <p>I thought that the "-Dorg.apache.commons......" command would go into the proguard-project.txt file but that caused the app to fail to even be built.  So bottom line, I don't understand what apache is trying to say and am hoping some of you experienced folks could provide some clarity/guidance.   </p>
  
  <p>Here's the stack trace:</p>
  
  <pre><code>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.&lt;init&gt;(Unknown Source)
  07-22 02:49:32.109: E/AndroidRuntime(13589):    at a.a.b.f.b.g.&lt;init&gt;(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): &lt;s3dReadConfigFile:75&gt;: Can't open file for reading
  07-22 02:49:32.169: E/(13589): &lt;s3dReadConfigFile:75&gt;: 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.&lt;init&gt;(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(:&lt;default&gt;):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(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.debug.log.FbLogImpl.f(FbLogImpl.java:147)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.debug.log.FbLogImpl.a(FbLogImpl.java:118)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.debug.log.BLog.a(BLog.java:790)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.e(DefaultBlueServiceOperationFactory.java:362)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.d(DefaultBlueServiceOperationFactory.java:103)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$1.b(DefaultBlueServiceOperationFactory.java:261)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.common.dispose.AbstractListenableDisposable.a(AbstractListenableDisposable.java:34)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.c(DefaultBlueServiceOperationFactory.java:288)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.a(DefaultBlueServiceOperationFactory.java:603)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.b(DefaultBlueServiceOperationFactory.java:561)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.c(DefaultBlueServiceOperationFactory.java:103)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation$4.run(DefaultBlueServiceOperationFactory.java:537)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.os.Handler.handleCallback(Handler.java:615)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.os.Handler.dispatchMessage(Handler.java:92)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.os.Looper.loop(Looper.java:137)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.app.ActivityThread.main(ActivityThread.java:4918)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at dalvik.system.NativeStart.main(Native Method)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):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(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:917)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.app.ContextImpl.unbindService(ContextImpl.java:1338)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at android.content.ContextWrapper.unbindService(ContextWrapper.java:412)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    at com.facebook.fbservice.ops.DefaultBlueServiceOperationFactory$DefaultOperation.e(DefaultBlueServiceOperationFactory.java:357)
  07-22 02:49:39.667: A/fb4a(:&lt;default&gt;):BlueServiceOperationFactory$Operation(11387):    ... 17 more
  </code></pre>