Note that there are some explanatory texts on larger screens.

plurals
  1. POHow come I get ClassNotFoundException when backupAgent tries to start
    primarykey
    data
    text
    <p>I use the <code>BackupAgentHelper</code> to backup the <code>SharedPreferences</code> in my Android app. I have tested it in the emulator (Android 1.6 and 2.2) and on my own phone (Android 2.3.3) and it all works well. However, today I got a crash report in the Developer Console looking like this:</p> <pre><code>java.lang.RuntimeException: Unable to create BackupAgent com.xxx.yyy.MyBackupAgent: java.lang.ClassNotFoundException: com.xxx.yyy.MyBackupAgent in loader dalvik.system.PathClassLoader[/mnt/asec/com.xxx.yyy-2/pkg.apk] at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:2114) at android.app.ActivityThread.access$3200(ActivityThread.java:132) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1138) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:143) at android.app.ActivityThread.main(ActivityThread.java:4196) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: com.xxx.yyy.MyBackupAgent in loader dalvik.system.PathClassLoader[/mnt/asec/com.xxx.yyy-2/pkg.apk] at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) at java.lang.ClassLoader.loadClass(ClassLoader.java:551) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at android.app.ActivityThread.handleCreateBackupAgent(ActivityThread.java:2064) ... 10 more </code></pre> <p>The backupAgent is declared in the application tag in the Manifest as:</p> <pre><code>android:backupAgent="com.xxx.yyy.MyBackupAgent" </code></pre> <p>Apparantly, the class <code>MyBackupAgent</code> <em>is</em> present since I can build the <code>.apk</code> and it runs just fine on several devices. So how can it be that it does not find the class here? One thing I notice in the message above is that the app seems to be installed in a path which have my package name AND an appended "-2" at the end. Can this cause the classloader to not see the class in my package since I specify the full package name and class in the <code>android:backupAgent</code>, or is that part irrelevant? Can anybody understand what the reason can be that the class cannot be found?</p> <p>Worth to mention is that my app can be installed on SD card. </p> <p>Excuse me for replacing my real package name with com.xxx.yyy in the message above.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload