AlexVPerl
AlexVPerl

Reputation: 7996

Rare Android Unable to Instantiate Application Exception

I'm seeing the following exception under Crashes in the dev console from time to time.

Whats puzzling about it is that google maps shows up in the call stack as if its calling or creating my app class - very confusing. Whats further weird is the "MyApp-2.apk" in the call stack - where it appends the "-2".

I do include the android.maps.jar file in the libs.

I would like to know how to recreate this if possible and how to prevent this from happening?

    java.lang.RuntimeException: Unable to instantiate application com.MyApp.MyCustomApp: 
java.lang.ClassNotFoundException: Didn't find class "com.MyApp.MyCustomApp" 
on path: /system/framework/com.google.android.maps.jar:/data/app/com.MyApp-2.apk
    at android.app.LoadedApk.makeApplication(LoadedApk.java:503)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4405)
    at android.app.ActivityThread.access$1400(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1327)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5059)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.MyApp.MyCustomApp" on path: /system/framework/com.google.android.maps.jar:/data/app/com.MyApp-2.apk
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.Instrumentation.newApplication(Instrumentation.java:967)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:498)
    ... 11 more

Manifest Application Tag:

 <application
        android:name=".MyApp"
        android:hardwareAccelerated="true"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:theme="@style/AppBaseTheme" >

I'm using these JARS: android-support-v4-r2-googlemaps.jar + android-support-v4.jar

Upvotes: 2

Views: 268

Answers (1)

Chris Stratton
Chris Stratton

Reputation: 40337

The prime reason why a Class within your application would be present on your test devices but missing at runtime on some others would be if your class has a dependency on some external feature which is missing on those devices. For example, if you used some Google API which is not part of AOSP and so missing on a plain AOSP build, or a vendor build which does not license these, then your class will be pruned at install time as its dependencies cannot be resolved.

A common reason for your app finding its way into such circumstances might be someone running an inconsistently assembled "custom ROM" on their device.

Upvotes: 2

Related Questions