I'm trying to add backup support to my app, and have set up a subclass of BackupAgentHelper as described in the Data Backup guide. I've compared my code to several other tutorials and SO posts and don't see any problems here:
public class MyBackupClass extends BackupAgentHelper {
public App app;
#Override
public void onCreate() {
Log.d("MyBackupClass", "** onCreate **");
// get the application delegate for convenience
this.app = (App)this.getApplicationContext();
// add the backup helpers
this.addHelpers();
}
public void addHelpers() {
Log.d("MyBackupClass", "** addHelpers **");
String name = "Sample Database";
// add a helper for the default shared preferences
String defaultSharedPrefsName = this.getPackageName() + "_preferences";
SharedPreferencesBackupHelper defaultPrefsHelper = new SharedPreferencesBackupHelper(this, defaultSharedPrefsName);
addHelper("default_prefs", defaultPrefsHelper);
// add a helper for the shared preferences
SharedPreferencesBackupHelper prefsHelper = new SharedPreferencesBackupHelper(this, name);
addHelper(name + "_prefs", prefsHelper);
// add a helper for the data file
FileBackupHelper dataHelper = new FileBackupHelper(this, name);
addHelper(name + "_data", dataHelper);
}
#Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) throws IOException {
// hold the lock while the FileBackupHelper performs the backup
synchronized (this.app.database.fileLock) {
Log.d("MyBackupClass", "** onBackup **");
super.onBackup(oldState, data, newState);
}
}
#Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException {
// hold the lock while the FileBackupHelper restores the file
synchronized (this.app.database.fileLock) {
Log.d("MyBackupClass", "** onRestore **");
super.onRestore(data, appVersionCode, newState);
}
}
}
I'm also running new BackupManager(this.app).dataChanged() whenever I save data.
On a device that's logged into a Google Play account and with the backup and restore options enabled in the device settings, I run ./adb -d shell bmgr run and get this result in the logcat:
D/AndroidRuntime( 3828):
D/AndroidRuntime( 3828): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 3828): CheckJNI is OFF
D/dalvikvm( 3828): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 3828): Added shared lib libjavacore.so 0x0
D/dalvikvm( 3828): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 3828): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 3828): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 3828): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 3828): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 3828): failed to load memtrack module: -2
D/AndroidRuntime( 3828): Calling main entry com.android.commands.bmgr.Bmgr
V/BackupManagerService( 433): Scheduling immediate backup pass
D/AndroidRuntime( 3828): Shutting down VM
D/dalvikvm( 3828): Debugger has detached; object registry had 1 entries
V/BackupManagerService( 433): Running a backup pass
V/BackupManagerService( 433): clearing pending backups
V/PerformBackupTask( 433): Beginning backup of 2 targets
V/BackupServiceBinder( 433): doBackup() invoked
D/PerformBackupTask( 433): invokeAgentForBackup on #pm#
I/PerformBackupTask( 433): no backup data written; not calling transport
D/PerformBackupTask( 433): starting agent for backup of BackupRequest{pkg=android}
D/BackupManagerService( 433): awaiting agent for ApplicationInfo{4196f698 android}
D/BackupManagerService( 433): agentConnected pkg=android agent=android.app.backup.BackupAgent$BackupServiceBinder#4203c550
I/BackupManagerService( 433): got agent android.app.backup.BackupAgent$BackupServiceBinder#4203c550
V/BackupServiceBinder( 433): doBackup() invoked
D/BackupHelperDispatcher( 433): handling existing helper 'wallpaper' android.app.backup.WallpaperBackupHelper#4226bb08
D/PerformBackupTask( 433): invokeAgentForBackup on android
D/PerformBackupTask( 433): starting agent for backup of BackupRequest{pkg=com.arlomedia.myapp}
D/BackupManagerService( 433): awaiting agent for ApplicationInfo{41e916b0 com.arlomedia.myapp}
D/MyBackupClass ( 3779): ** onCreate **
D/MyBackupClass ( 3779): ** addHelpers **
D/BackupManagerService( 433): agentConnected pkg=com.arlomedia.myapp agent=android.os.BinderProxy#41e45118
I/BackupManagerService( 433): got agent android.app.IBackupAgent$Stub$Proxy#421a63e8
V/BackupServiceBinder( 3779): doBackup() invoked
D/MyBackupClass ( 3779): ** onBackup **
D/BackupHelperDispatcher( 3779): handling new helper 'Sample Database_data'
D/PerformBackupTask( 433): invokeAgentForBackup on com.arlomedia.myapp
D/BackupHelperDispatcher( 3779): handling new helper 'Sample Database_prefs'
D/BackupHelperDispatcher( 3779): handling new helper 'default_prefs'
I/PerformBackupTask( 433): Backup pass finished.
The parts about handling the helpers I set up, and the "backup pass finished" seem to indicate that the backup is working. Then, I uninstall the app and reinstall it with ./adb -d install and get the following result:
D/AndroidRuntime( 3875): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 3875): CheckJNI is OFF
D/dalvikvm( 3875): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 3875): Added shared lib libjavacore.so 0x0
D/dalvikvm( 3875): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 3875): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 3875): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 3875): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 3875): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 3875): failed to load memtrack module: -2
D/AndroidRuntime( 3875): Calling main entry com.android.commands.pm.Pm
D/Finsky (23657): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 142
W/ActivityManager( 433): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
D/Finsky (23657): [1] WorkerTask.onPreExecute: Verification Requested for id = 142, data=file:///data/local/tmp/app-debug.apk flags=112 fromVerificationActivity=false
D/dalvikvm(23657): GC_CONCURRENT freed 1940K, 21% free 8146K/10228K, paused 2ms+1ms, total 34ms
D/dalvikvm(23657): GC_FOR_ALLOC freed 993K, 21% free 8130K/10228K, paused 23ms, total 24ms
D/dalvikvm(23657): GC_FOR_ALLOC freed 980K, 21% free 8136K/10228K, paused 23ms, total 23ms
D/dalvikvm(23657): GC_FOR_ALLOC freed 1051K, 20% free 8208K/10228K, paused 23ms, total 23ms
I/qtaguid (23657): Failed write_ctrl(u 74) res=-1 errno=22
I/qtaguid (23657): Untagging socket 74 failed errno=-22
W/NetworkManagementSocketTagger(23657): untagSocket(74) failed with errno -22
D/Finsky (23657): [1] 2.onResponse: Verification id=142 response=0
D/Finsky (23657): [1] PackageVerificationReceiver.onReceive: Verification requested, id = 142
W/ActivityManager( 433): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
I/PackageManager( 433): Copying native libraries to /data/app-lib/vmdl-2084848498
D/dalvikvm( 433): GC_CONCURRENT freed 2945K, 34% free 14565K/21864K, paused 4ms+6ms, total 62ms
D/dalvikvm( 433): WAIT_FOR_CONCURRENT_GC blocked 14ms
D/dalvikvm( 433): WAIT_FOR_CONCURRENT_GC blocked 14ms
D/dalvikvm( 433): WAIT_FOR_CONCURRENT_GC blocked 46ms
I/PackageManager( 433): Running dexopt on: com.arlomedia.myapp
D/dalvikvm( 3888): DexOpt: load 64ms, verify+opt 570ms, 2417268 bytes
D/Finsky (23657): [1] 5.onFinished: Installation state replication succeeded.
I/ActivityManager( 433): Force stopping com.arlomedia.myapp appid=10140 user=-1: update pkg
V/BackupManagerService( 433): restoreAtInstall pkg=com.arlomedia.myapp token=8f restoreSet=3c51dd81eebd5a3d
D/BackupManagerService( 433): MSG_RUN_RESTORE observer=null
V/BackupServiceBinder( 433): doRestore() invoked
D/BackupManagerService( 433): initiateOneRestore packageName=#pm#
V/BackupManagerService( 433): Package com.arlomedia.myapp restore version [25] is compatible with installed version [25]
I/ActivityManager( 433): Start proc com.arlomedia.myapp for backup com.arlomedia.myapp/.helpers.Backups: pid=3889 uid=10140 gids={50140, 3003, 1028, 1015}
D/dalvikvm( 3889): Late-enabling CheckJNI
D/BackupManagerService( 433): awaiting agent for ApplicationInfo{4226acf0 com.arlomedia.myapp}
D/MyBackupClass ( 3779): ** onCreate **
D/MyBackupClass ( 3779): ** addHelpers **
D/BackupManagerService( 433): agentConnected pkg=com.arlomedia.myapp agent=android.os.BinderProxy#423dd558
I/BackupManagerService( 433): got agent android.app.IBackupAgent$Stub$Proxy#41d66818
D/BackupManagerService( 433): initiateOneRestore packageName=com.arlomedia.myapp
V/BackupServiceBinder( 3889): doRestore() invoked
D/MyBackupClass ( 3779): ** onRestore **
D/backup_data( 3889): SKIP_PADDING FAILED at line 332
V/BackupManagerService( 433): No next package, finishing restore
I/BackupManagerService( 433): Restore complete.
The parts about "restore version is compatible" and "restore complete" look promising, but no data is restored. I see the error "SKIP_PADDING FAILED," but I don't know if that's relevant to what I'm doing or how to fix it if it is.
I also tried this with an emulator using the local transport. Running the backup manager gives this result:
D/AndroidRuntime( 5503):
D/AndroidRuntime( 5503): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
W/linker ( 5503): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/AndroidRuntime( 5503): CheckJNI is ON
D/dalvikvm( 5503): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5503): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5503): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5503): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5503): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 5503): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 5503): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5503): failed to load memtrack module: -2
D/AndroidRuntime( 5503): Calling main entry com.android.commands.bmgr.Bmgr
V/BackupServiceBinder( 1276): doBackup() invoked
V/BackupManagerService( 1276): Scheduling immediate backup pass
V/BackupManagerService( 1276): Running a backup pass
V/BackupManagerService( 1276): clearing pending backups
V/PerformBackupTask( 1276): Beginning backup of 2 targets
D/PerformBackupTask( 1276): invokeAgentForBackup on #pm#
I/PerformBackupTask( 1276): no backup data written; not calling transport
D/PerformBackupTask( 1276): starting agent for backup of BackupRequest{pkg=android}
D/BackupManagerService( 1276): awaiting agent for ApplicationInfo{b10042c8 android}
V/BackupServiceBinder( 1276): doBackup() invoked
D/BackupHelperDispatcher( 1276): handling existing helper 'wallpaper' android.app.backup.WallpaperBackupHelper#b12f0e70
V/LocalTransport( 1276): performBackup() pkg=android
V/LocalTransport( 1276): Got change set key=wallpaper:/data/system/wallpaper_info.xml size=-1 key64=d2FsbHBhcGVyOi9kYXRhL3N5c3RlbS93YWxscGFwZXJfaW5mby54bWw=
V/LocalTransport( 1276): Got change set key=wallpaper:/data/system/wallpaper_info.xml size=115 key64=d2FsbHBhcGVyOi9kYXRhL3N5c3RlbS93YWxscGFwZXJfaW5mby54bWw=
V/LocalTransport( 1276): data size 115
V/LocalTransport( 1276): finishBackup()
D/MyBackupClass ( 3779): ** onCreate **
D/MyBackupClass ( 3779): ** addHelpers **
V/BackupServiceBinder( 5427): doBackup() invoked
D/MyBackupClass ( 3779): ** onBackup **
D/BackupHelperDispatcher( 5427): handling new helper 'Sample Database_data'
D/BackupHelperDispatcher( 5427): handling new helper 'Sample Database_prefs'
D/BackupHelperDispatcher( 5427): handling new helper 'default_prefs'
V/LocalTransport( 1276): performBackup() pkg=com.arlomedia.myapp
V/LocalTransport( 1276): Got change set key=Sample Database_data:Sample Database size=1755 key64=U2FtcGxlIERhdGFiYXNlX2RhdGE6U2FtcGxlIERhdGFiYXNl
V/LocalTransport( 1276): data size 1755
V/LocalTransport( 1276): Got change set key=Sample Database_prefs:Sample Database size=4186 key64=U2FtcGxlIERhdGFiYXNlX3ByZWZzOlNhbXBsZSBEYXRhYmFzZQ==
V/LocalTransport( 1276): data size 4186
V/LocalTransport( 1276): Got change set key=default_prefs:com.arlomedia.myapp_preferences size=356 key64=ZGVmYXVsdF9wcmVmczpjb20uYXJsb21lZGlhLnNldGxpc3RtYWtlcl9wcmVmZXJlbmNlcw==
V/LocalTransport( 1276): data size 356
V/LocalTransport( 1276): finishBackup()
D/BackupManagerService( 1276): agentConnected pkg=android agent=android.app.backup.BackupAgent$BackupServiceBinder#b1382ba0
I/BackupManagerService( 1276): got agent android.app.backup.BackupAgent$BackupServiceBinder#b1382ba0
D/PerformBackupTask( 1276): invokeAgentForBackup on android
D/PerformBackupTask( 1276): starting agent for backup of BackupRequest{pkg=com.arlomedia.myapp}
D/BackupManagerService( 1276): awaiting agent for ApplicationInfo{b158e9a8 com.arlomedia.myapp}
D/BackupManagerService( 1276): agentConnected pkg=com.arlomedia.myapp agent=android.os.BinderProxy#b13cdbf0
I/BackupManagerService( 1276): got agent android.app.IBackupAgent$Stub$Proxy#b13ad550
D/PerformBackupTask( 1276): invokeAgentForBackup on com.arlomedia.myapp
I/PerformBackupTask( 1276): Backup pass finished.
D/AndroidRuntime( 5503): Shutting down VM
D/dalvikvm( 5503): Debugger has detached; object registry had 1 entries
I/AndroidRuntime( 5503): NOTE: attach of thread 'Binder_1' failed
And reinstalling gives this result:
D/AndroidRuntime( 5530):
D/AndroidRuntime( 5530): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
W/linker ( 5530): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/AndroidRuntime( 5530): CheckJNI is ON
D/dalvikvm( 5530): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 5530): Added shared lib libjavacore.so 0x0
D/dalvikvm( 5530): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 5530): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 5530): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 5530): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 5530): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 5530): failed to load memtrack module: -2
D/AndroidRuntime( 5530): Calling main entry com.android.commands.pm.Pm
W/ActivityManager( 1276): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
W/ActivityManager( 1276): No content provider found for permission revoke: file:///data/local/tmp/app-debug.apk
I/PackageManager( 1276): Copying native libraries to /data/app-lib/vmdl2051152188
D/dalvikvm( 1276): GC_FOR_ALLOC freed 1352K, 21% free 7636K/9604K, paused 6ms, total 8ms
D/dalvikvm( 1276): GC_FOR_ALLOC freed 1002K, 19% free 7834K/9604K, paused 66ms, total 66ms
D/dalvikvm( 1276): GC_FOR_ALLOC freed 947K, 19% free 7840K/9604K, paused 7ms, total 7ms
D/dalvikvm( 1276): GC_FOR_ALLOC freed 946K, 19% free 7848K/9604K, paused 9ms, total 10ms
I/PackageManager( 1276): Running dexopt on: com.arlomedia.myapp
W/linker ( 5542): libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
D/dalvikvm( 5542): DexOpt: load 15ms, verify+opt 149ms, 2414236 bytes
I/ActivityManager( 1276): Force stopping com.arlomedia.myapp appid=10067 user=-1: update pkg
W/PackageManager( 1276): Unknown permission com.android.vending.CHECK_LICENSE in package com.arlomedia.myapp
W/PackageManager( 1276): Unknown permission com.android.vending.BILLING in package com.arlomedia.myapp
V/LocalTransport( 1276): start restore 1
V/LocalTransport( 1276): nextRestorePackage() = #pm#
V/LocalTransport( 1276): getRestoreData() found 10 key files
V/LocalTransport( 1276): ... key=#meta# size=0
V/LocalTransport( 1276): ... key=com.android.calendar size=0
V/LocalTransport( 1276): ... key=com.android.browser size=0
V/LocalTransport( 1276): ... key=com.android.providers.userdictionary size=0
V/LocalTransport( 1276): ... key=com.android.sharedstoragebackup size=0
V/LocalTransport( 1276): ... key=android size=0
V/LocalTransport( 1276): ... key=com.android.dialer size=0
V/LocalTransport( 1276): ... key=com.android.providers.settings size=0
V/LocalTransport( 1276): ... key=com.arlomedia.myapp size=635
V/LocalTransport( 1276): ... key=com.arlomedia.myotherapp size=635
V/BackupServiceBinder( 1276): doRestore() invoked
D/BackupServiceBinder( 1276): onRestore (com.android.server.PackageManagerBackupAgent) threw
D/BackupServiceBinder( 1276): java.io.EOFException
D/BackupServiceBinder( 1276): at libcore.io.Streams.readFully(Streams.java:83)
D/BackupServiceBinder( 1276): at java.io.DataInputStream.readInt(DataInputStream.java:103)
D/BackupServiceBinder( 1276): at com.android.server.PackageManagerBackupAgent.onRestore(PackageManagerBackupAgent.java:273)
D/BackupServiceBinder( 1276): at android.app.backup.BackupAgent$BackupServiceBinder.doRestore(BackupAgent.java:599)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.initiateOneRestore(BackupManagerService.java:4842)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.restorePmMetadata(BackupManagerService.java:4595)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.execute(BackupManagerService.java:4453)
D/BackupServiceBinder( 1276): at com.android.server.BackupManagerService$BackupHandler.handleMessage(BackupManagerService.java:573)
D/BackupServiceBinder( 1276): at android.os.Handler.dispatchMessage(Handler.java:102)
D/BackupServiceBinder( 1276): at android.os.Looper.loop(Looper.java:136)
D/BackupServiceBinder( 1276): at android.os.HandlerThread.run(HandlerThread.java:61)
V/LocalTransport( 1276): nextRestorePackage() = com.arlomedia.myapp
V/LocalTransport( 1276): no more packages to restore
V/LocalTransport( 1276): finishRestore()
V/BackupManagerService( 1276): restoreAtInstall pkg=com.arlomedia.myapp token=17 restoreSet=1
D/BackupManagerService( 1276): MSG_RUN_RESTORE observer=null
D/BackupManagerService( 1276): initiateOneRestore packageName=#pm#
E/BackupManagerService( 1276): Unable to call app for restore: #pm#
E/BackupManagerService( 1276): java.lang.RuntimeException: java.io.EOFException
E/BackupManagerService( 1276): at android.app.backup.BackupAgent$BackupServiceBinder.doRestore(BackupAgent.java:602)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.initiateOneRestore(BackupManagerService.java:4842)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.restorePmMetadata(BackupManagerService.java:4595)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$PerformRestoreTask.execute(BackupManagerService.java:4453)
E/BackupManagerService( 1276): at com.android.server.BackupManagerService$BackupHandler.handleMessage(BackupManagerService.java:573)
E/BackupManagerService( 1276): at android.os.Handler.dispatchMessage(Handler.java:102)
E/BackupManagerService( 1276): at android.os.Looper.loop(Looper.java:136)
E/BackupManagerService( 1276): at android.os.HandlerThread.run(HandlerThread.java:61)
E/BackupManagerService( 1276): Caused by: java.io.EOFException
E/BackupManagerService( 1276): at libcore.io.Streams.readFully(Streams.java:83)
E/BackupManagerService( 1276): at java.io.DataInputStream.readInt(DataInputStream.java:103)
E/BackupManagerService( 1276): at com.android.server.PackageManagerBackupAgent.onRestore(PackageManagerBackupAgent.java:273)
E/BackupManagerService( 1276): at android.app.backup.BackupAgent$BackupServiceBinder.doRestore(BackupAgent.java:599)
E/BackupManagerService( 1276): ... 7 more
W/BackupManagerService( 1276): Tried to clear data for #pm# but not found
E/BackupManagerService( 1276): No restore metadata available, so not restoring settings
W/PMBA ( 1276): getRestoredMetadata() before metadata read!
E/BackupManagerService( 1276): Missing metadata for com.arlomedia.myapp
V/BackupManagerService( 1276): No next package, finishing restore
I/BackupManagerService( 1276): Restore complete.
In this case, the backup process shows the size of the data backed up, which is even more promising, but then the restore process crashes with an EOFException and I don't know how to fix that. Again, nothing is restored.
Ultimately I only need this to work on real devices, but I'm posting the results from the emulator in case it provides any clues.
Can anyone help me interpret these logs to find out what's wrong?
I'd also appreciate a quick comment saying whether or not you've gotten this system to work, because several SO threads are unanswered or have concluded that the system just doesn't work.
Update
After studying these logs further, it seems there are no relevant errors while backing up from the device or the emulator, but there is a different error thrown at a critical point while restoring each of them -- SKIP_PADDING FAILED on the device and EOFException on the emulator. SKIP_PADDING FAILED is mentioned in these two unanswered questions:
backup_data: SKIP_PADDING FAILED at line X
Android Data Backup service
I tried reading the source code for SKIP_PADDING FAILED, but couldn't understand what it was doing. Next I added this code to my onRestore method to see whether the BackupDataInput object contains my data:
while (data.readNextHeader()) {
String key = data.getKey();
int dataSize = data.getDataSize();
byte[] buffer = new byte[dataSize];
data.readEntityData(buffer, 0, dataSize);
Log.d("Backups", "restoring key " + key);
Log.d("Backups", "restoring data size " + dataSize);
Log.d("Backups", "restoring data " + new String(buffer, "UTF-8"));
}
It does! So now I can see that my data is getting backed up, but something in BackupAgent.performRestore (which is called by BackupAgentHelper.onRestore) is breaking. I think I could work around that by saving the data files myself in the onRestore method. Does anyone have a better solution?
I came back to this after a week, tried again and now the backups are restoring. I haven't been able to identify anything I'm doing differently now, so I can't offer a solution to whatever problem was happening before. But now that it's working, I can clarify a few things about the Android backup service:
Contrary to other SO answers I have seen, this system does work, at least sometimes
The SKIP_PADDING FAILED error is still occurring, but isn't stopping the restore from working correctly, so that was a red herring
The backup/restore is working for me in an Android 5.0 emulator and on Android 4.4 and 4.1 devices, so it seems to have good compatibility
Related
I'm trying to install Adobe Air (com.adobe.air) in a Genymotion emulator emulating a Galaxy S4 with android 4.4.4 and I am getting:
Failure [INSTALL_FAILED_INVALID_APK]
With adb logcat I can see:
D/AndroidRuntime( 2350):
D/AndroidRuntime( 2350): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 2350): CheckJNI is OFF
D/dalvikvm( 2350): Trying to load lib libjavacore.so 0x0
D/dalvikvm( 2350): Added shared lib libjavacore.so 0x0
D/dalvikvm( 2350): Trying to load lib libnativehelper.so 0x0
D/dalvikvm( 2350): Added shared lib libnativehelper.so 0x0
D/dalvikvm( 2350): No JNI_OnLoad found in libnativehelper.so 0x0, skipping init
D/dalvikvm( 2350): Note: class Landroid/app/ActivityManagerNative; has 179 unimplemented (abstract) methods
E/memtrack( 2350): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 2350): failed to load memtrack module: -2
D/AndroidRuntime( 2350): Calling main entry com.android.commands.pm.Pm
W/ActivityManager( 517): No content provider found for permission revoke: file:///data/local/tmp/Adobe.AIR.v16.0.0.259_www.revdl.com.apk
W/ActivityManager( 517): No content provider found for permission revoke: file:///data/local/tmp/Adobe.AIR.v16.0.0.259_www.revdl.com.apk
I/PackageManager( 517): Copying native libraries to /data/app-lib/vmdl1421280503
D/dalvikvm( 517): GC_FOR_ALLOC freed 1626K, 20% free 10767K/13324K, paused 12ms, total 12ms
D/dalvikvm( 517): GC_FOR_ALLOC freed 309K, 17% free 11063K/13324K, paused 9ms, total 9ms
D/dalvikvm( 517): GC_FOR_ALLOC freed 1138K, 17% free 11163K/13324K, paused 11ms, total 11ms
D/dalvikvm( 517): GC_FOR_ALLOC freed 1036K, 17% free 11173K/13324K, paused 11ms, total 12ms
D/dalvikvm( 517): GC_FOR_ALLOC freed 996K, 17% free 11171K/13324K, paused 9ms, total 10ms
D/dalvikvm( 517): GC_FOR_ALLOC freed 985K, 17% free 11176K/13324K, paused 11ms, total 12ms
D/dalvikvm( 517): GC_FOR_ALLOC freed 987K, 17% free 11184K/13324K, paused 9ms, total 9ms
D/xmlCheckExt( 517): <filter>
D/xmlCheckExt( 517): pkgName = org.mozilla.firefox
D/xmlCheckExt( 517): <filter>
D/xmlCheckExt( 517): pkgName = org.mozilla.firefox_beta
D/xmlCheckExt( 517): <filter>
D/xmlCheckExt( 517): pkgName = com.good.android.gfe
D/xmlCheckExt( 517): <filter>
D/xmlCheckExt( 517): pkgName = com.adobe.air
I/PackageManager( 517): Package with second ABI is in black list: 10079com.adobe.air
W/PackageManager( 517): Package couldn't be installed in /data/app/com.adobe.air-1.apk
D/dalvikvm( 517): GC_EXPLICIT freed 1038K, 17% free 11162K/13324K, paused 1ms+1ms, total 12ms
D/AndroidRuntime( 2350): Shutting down VM
I noted the following piece in the log:
D/xmlCheckExt( 517): pkgName = com.adobe.air
I/PackageManager( 517): Package with second ABI is in black list: 10079com.adobe.air
But when I try:
adb shell pm unblock com.adobe.air
I'm getting:
Package com.adobe.air new blocked state: true
How can I unblock / remove from the blacklist Adobe Air package?
I think that you could find the apk in the sdk folder. In mac is here:
/Applications/Research In Motion/blackberry-tablet-sdk-3.2.1/runtimes/air
Why is the debug window empty debugging an Android app that does not include a MAIN and LAUNCH activity, but only a receiver? Is it normal or there is something wrong?
When I launch the app in debug mode this is the LogCat:
10-24 13:02:52.998: D/AndroidRuntime(5782): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
10-24 13:02:52.998: D/AndroidRuntime(5782): CheckJNI is ON
10-24 13:02:53.108: D/dalvikvm(5782): Trying to load lib libjavacore.so 0x0
10-24 13:02:53.118: D/dalvikvm(5782): Added shared lib libjavacore.so 0x0
10-24 13:02:53.159: D/dalvikvm(5782): Trying to load lib libnativehelper.so 0x0
10-24 13:02:53.168: D/dalvikvm(5782): Added shared lib libnativehelper.so 0x0
10-24 13:02:54.324: D/AndroidRuntime(5782): Calling main entry com.android.commands.pm.Pm
10-24 13:02:54.398: D/AndroidRuntime(5782): Shutting down VM
10-24 13:02:54.418: D/dalvikvm(5782): GC_CONCURRENT freed 102K, 78% free 466K/2048K, paused 1ms+3ms, total 22ms
10-24 13:02:54.448: D/dalvikvm(5782): Debugger has detached; object registry had 1 entries
10-24 13:04:07.651: E/ThrottleService(159): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
10-24 13:05:07.188: E/MP3Extractor(39): Unable to resync. Signalling end of stream.
10-24 13:05:08.118: I/AudioService(159): AudioFocus abandonAudioFocus() from android.media.AudioManager#412af538
10-24 13:06:00.370: D/dalvikvm(220): GC_CONCURRENT freed 386K, 57% free 9099K/20743K, paused 74ms+10ms, total 195ms
This is the Console window
[2012-10-24 15:02:53 - SMSApp] ------------------------------
[2012-10-24 15:02:53 - SMSApp] Android Launch!
[2012-10-24 15:02:53 - SMSApp] adb is running normally.
[2012-10-24 15:02:53 - SMSApp] No Launcher activity found!
[2012-10-24 15:02:53 - SMSApp] The launch will only sync the application package on the device!
[2012-10-24 15:02:53 - SMSApp] Performing sync
[2012-10-24 15:02:53 - SMSApp] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'NFC-Smartphone-1'
[2012-10-24 15:02:55 - SMSApp] Application already deployed. No need to reinstall.
[2012-10-24 15:02:55 - SMSApp] \SMSApp\bin\SMSApp.apk installed on device
[2012-10-24 15:02:55 - SMSApp] Done!
As you can see the application was already installed on the emulator, but the same issue is present when the application is installed for the first time.
Let me know whether it is useful to see also the code.
I tried with a slightly different version of the same app just to force Eclipse to reinstall the app in the emulator (added a space). This is the LogCat of the reinstallation:
10-25 12:43:14.628: D/AndroidRuntime(701): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
10-25 12:43:14.628: D/AndroidRuntime(701): CheckJNI is ON
10-25 12:43:14.687: D/dalvikvm(701): Trying to load lib libjavacore.so 0x0
10-25 12:43:14.707: D/dalvikvm(701): Added shared lib libjavacore.so 0x0
10-25 12:43:14.747: D/dalvikvm(701): Trying to load lib libnativehelper.so 0x0
10-25 12:43:14.747: D/dalvikvm(701): Added shared lib libnativehelper.so 0x0
10-25 12:43:15.647: D/AndroidRuntime(701): Calling main entry com.android.commands.pm.Pm
10-25 12:43:15.707: W/ActivityManager(148): No content provider found for permission revoke: file:///data/local/tmp/SMSApp.apk
10-25 12:43:15.737: W/ActivityManager(148): No content provider found for permission revoke: file:///data/local/tmp/SMSApp.apk
10-25 12:43:15.917: I/PackageManager(148): Removing non-system package:com.storassa.android.smsapp
10-25 12:43:15.917: I/ActivityManager(148): Force stopping package com.storassa.android.smsapp uid=10044
10-25 12:43:15.967: I/dalvikvm(148): Jit: resizing JitTable from 4096 to 8192
10-25 12:43:16.088: I/PackageManager(148): Package com.storassa.android.smsapp codePath changed from /data/app/com.storassa.android.smsapp-2.apk to /data/app/com.storassa.android.smsapp-1.apk; Retaining data and using new
10-25 12:43:16.098: I/PackageManager(148): Running dexopt on: com.storassa.android.smsapp
10-25 12:43:16.948: D/dalvikvm(715): DexOpt: load 124ms, verify+opt 526ms, 730780 bytes
10-25 12:43:16.977: I/ActivityManager(148): Force stopping package com.storassa.android.smsapp uid=10044
10-25 12:43:16.977: W/PackageManager(148): Code path for pkg : com.storassa.android.smsapp changing from /data/app/com.storassa.android.smsapp-2.apk to /data/app/com.storassa.android.smsapp-1.apk
10-25 12:43:16.977: W/PackageManager(148): Resource path for pkg : com.storassa.android.smsapp changing from /data/app/com.storassa.android.smsapp-2.apk to /data/app/com.storassa.android.smsapp-1.apk
10-25 12:43:17.067: D/PackageManager(148): New package installed in /data/app/com.storassa.android.smsapp-1.apk
10-25 12:43:17.337: D/dalvikvm(148): GC_CONCURRENT freed 664K, 8% free 11375K/12231K, paused 77ms+12ms, total 180ms
10-25 12:43:17.337: D/dalvikvm(148): WAIT_FOR_CONCURRENT_GC blocked 100ms
Another tips: no saved filters appears in LogCat.
I wonder if you can help me with this error.
I am running a fresh fully updated install of windows 7 with
Visual studio 2010 Professional in trial mode.
In Visual Studio I create a new OpenGl Mono for Android Application
using the built in template.
I compile and run the application.
The emulator boots (I am running API_8) EMU.
The application starts and then aborts.
(In the emulator I get a black screen which quickly closes.)
Same thing happens if I do similar using the Mono Develop IDE
and or the other templates.
Here is a dump of the error message (I cannot find much info on google)
It looks like the error is related to the load library fail.
Thanks
// DUMP
03-05 23:23:47.464 D/AndroidRuntime( 418):
03-05 23:23:47.464 D/AndroidRuntime( 418): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-05 23:23:47.464 D/AndroidRuntime( 418): CheckJNI is ON
03-05 23:23:47.574 D/AndroidRuntime( 418): --- registering native functions ---
03-05 23:23:48.034 I/ActivityManager( 60): Start proc OpenGLApplication1.OpenGLApplication1 for broadcast OpenGLApplication1.OpenGLApplication1/mono.android.Seppuku: pid=424 uid=10038 gids={3003, 1015}
03-05 23:23:48.164 I/ActivityThread( 424): Publishing provider OpenGLApplication1.OpenGLApplication1.__mono_init__: mono.MonoRuntimeProvider
03-05 23:23:48.174 D/dalvikvm( 424): Trying to load lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:48.174 D/dalvikvm( 424): Added shared lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:48.184 F/MonoDroid( 424): shared runtime initialization error: Cannot load library: load_library[1083]: Library '/data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so' not found
03-05 23:23:48.204 I/ActivityManager( 60): Process OpenGLApplication1.OpenGLApplication1 (pid 424) has died.
03-05 23:23:48.214 D/AndroidRuntime( 418): Shutting down VM
03-05 23:23:48.214 D/jdwp ( 418): adbd disconnected
03-05 23:23:48.624 D/AndroidRuntime( 432):
03-05 23:23:48.624 D/AndroidRuntime( 432): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-05 23:23:48.624 D/AndroidRuntime( 432): CheckJNI is ON
03-05 23:23:48.734 D/AndroidRuntime( 432): --- registering native functions ---
03-05 23:23:49.173 I/ActivityManager( 60): Start proc OpenGLApplication1.OpenGLApplication1 for broadcast OpenGLApplication1.OpenGLApplication1/mono.android.Seppuku: pid=438 uid=10038 gids={3003, 1015}
03-05 23:23:49.294 I/ActivityThread( 438): Publishing provider OpenGLApplication1.OpenGLApplication1.__mono_init__: mono.MonoRuntimeProvider
03-05 23:23:49.303 D/dalvikvm( 438): Trying to load lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:49.303 D/dalvikvm( 438): Added shared lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7f010
03-05 23:23:49.314 F/MonoDroid( 438): shared runtime initialization error: Cannot load library: load_library[1083]: Library '/data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so' not found
03-05 23:23:49.334 I/ActivityManager( 60): Process OpenGLApplication1.OpenGLApplication1 (pid 438) has died.
03-05 23:23:49.344 D/AndroidRuntime( 432): Shutting down VM
03-05 23:23:49.344 D/jdwp ( 432): adbd disconnected
03-05 23:23:50.333 D/AndroidRuntime( 447):
03-05 23:23:50.333 D/AndroidRuntime( 447): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
03-05 23:23:50.333 D/AndroidRuntime( 447): CheckJNI is ON
03-05 23:23:50.443 D/AndroidRuntime( 447): --- registering native functions ---
03-05 23:23:50.873 I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=OpenGLApplication1.OpenGLApplication1/openglapplication1.Activity1 }
03-05 23:23:50.893 I/ActivityManager( 60): Start proc OpenGLApplication1.OpenGLApplication1 for activity OpenGLApplication1.OpenGLApplication1/openglapplication1.Activity1: pid=453 uid=10038 gids={3003, 1015}
03-05 23:23:50.923 D/AndroidRuntime( 447): Shutting down VM
03-05 23:23:50.923 D/jdwp ( 447): adbd disconnected
03-05 23:23:50.953 I/AndroidRuntime( 447): NOTE: attach of thread 'Binder Thread #3' failed
03-05 23:23:51.173 I/ActivityThread( 453): Publishing provider OpenGLApplication1.OpenGLApplication1.__mono_init__: mono.MonoRuntimeProvider
03-05 23:23:51.223 D/dalvikvm( 453): Trying to load lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7eef0
03-05 23:23:51.223 D/dalvikvm( 453): Added shared lib /data/data/OpenGLApplication1.OpenGLApplication1/lib/libmonodroid.so 0x44e7eef0
03-05 23:23:51.263 F/MonoDroid( 453): shared runtime initialization error: Cannot load library: load_library[1083]: Library '/data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so' not found
03-05 23:23:51.283 I/ActivityManager( 60): Process OpenGLApplication1.OpenGLApplication1 (pid 453) has died.
03-05 23:23:51.293 I/UsageStats( 60): Unexpected resume of com.android.launcher while already resumed in OpenGLApplication1.OpenGLApplication1
03-05 23:23:51.423 W/InputManagerService( 60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#45104b68
The issue is from the newer versions of mono where libmonosgen-2.0 does not get installed automatically. The path that you will see in which it fails is actually a simlink for the library. What you have to do is manually or through a non-mono apk, create the following:
A folder with your package name in /data/app-lib/
in the folder you will have to push the libmonosgen-2.0.so (and libmonodroid.so if needed)
After this is done you have to navigate to data/data/your.package.name and create a simlink from lib -> the folder you created previously. the command to use is ln -s.
I have noticed that in some cases the simlink exists, but is pointing to a false location.
I had to do this manually and it would not survive a factory reset. A colleugue of mine actually did this the non-mono apk path which does everything for him when ever the provisioning app executes on first launch.
Try going to the project properties and turn off "fast deployment". Then manually remove your app from the emu/device, and try again.
Another possibility is that you don't have enough free space on your device. The problem isn't in your package (OpenGLApplication1), the problem is from installing the Mono.Android.DebugRuntime package, as /data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so doesn't exist.
I would suggest looking through the adb logcat log, and see if something like the following is present:
W/NativeHelper( 98): Failed to cache package shared libs
W/NativeHelper( 98): java.io.IOException: Couldn't create cached binary /data/data/Mono.Android.DebugRuntime/lib/libmonosgen-2.0.so in /data/data/Mono.Android.DebugRuntime/lib
W/NativeHelper( 98): at com.android.internal.content.NativeLibraryHelper.copyNativeBinaryLI(NativeLibraryHelper.java:289)
If messages like the above are present, remove the Mono.Android.DebugRuntime package (adb uninstall Mono.Android.DebugRuntime), remove some extra apps from your device (to free up space), and try re-installing your app from the IDE.
There are some data in my Android app that I would like to backup and restore. For that purpose I have created a custom implementation of BackupAgent.
In my manifest in have included the backup agent as you can see below
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
package="com.myapp"
android:versionCode="14"
android:versionName="1.13" >
<application
android:backupAgent="com.myapp.MyBackupAgent">
<meta-data
android:name="com.google.android.backup.api_key"
android:value="my key" />
I have included the backup service api key, although I am testing with the emulator (Android 2.2) and it should not be necessary, because it uses the local backup transport.
In order to do the test of the backup and restore I have done the following:
Start the emulator with my application installed.
Enable backup
adb shell bmgr enable true
Call the part of my code were the dataChanged method in the BackupManager class is called.
Initiate manually the backup operation
adb shell bmgr run
Checked in the log that the onBackup method of my custom BackupAgent was called.
Uninstall the app
Reinstall the app
Check in the log if the onRestore method is called.
The thing is that the onRestore method does not seem to be called and I don't know why. After reinstalling the app or manually triggering the restore with adb I see the following in the console.
$adb shell bmgr restore com.myapp
restoreStarting: 2 packages
restoreFinished: 0
done
and this other in the log
D/AndroidRuntime( 8259):
D/AndroidRuntime( 8259): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 8259): CheckJNI is ON
D/AndroidRuntime( 8259): --- registering native functions ---
D/BackupManagerService( 59): MSG_RUN_RESTORE observer=android.app.backup.IRestoreObserver$Stub$Proxy#450e16a8
V/LocalTransport( 59): start restore 1
V/LocalTransport( 59): nextRestorePackage() = #pm#
V/LocalTransport( 59): getRestoreData() found 7 key files
V/LocalTransport( 59): ... key=com.android.providers.settings size=1208
V/LocalTransport( 59): ... key=com.myapp size=501
V/LocalTransport( 59): ... key=android size=1208
V/LocalTransport( 59): ... key=com.android.providers.userdictionary size=1208
V/LocalTransport( 59): ... key=com.android.browser size=1208
V/LocalTransport( 59): ... key=com.android.inputmethod.latin size=1208
V/LocalTransport( 59): ... key=#meta# size=11
V/LocalTransport( 59): no more packages to restore
V/LocalTransport( 59): finishRestore()
V/LocalTransport( 59): finishRestore()
D/AndroidRuntime( 8259): Shutting down VM
but I don't see that the call to onRestore is actually made (I have some logging statements just at the beginning of it?
Has this ever happen to you? Is there any reason by the onRestore method is not called, even in the onBackup was called?
In my experience, for some odd reason (which I have yet to identify), logging statements made in BackupAgents don't show up in the logs. Nonetheless, I have been able to confirm that the onRestore method is in fact properly run.
In your question you indicate that the onRestore method "does not seem to be called" because you are unable to see the proper logs. Can you instead confirm that the result is failing (i.e. that data that should be properly restored isn't)?
I had this problem and the root cause was that I had a bug in my onBackup preventing it from completing, so onBackup was called but onRestore was not. Fixing the exception in onBackup caused onRestore to be called.
Also Log messages in onBackup and onRestore do show up in the logs. If you set a log filter on the tag "backup" and use something with backup in it for your log tag. You will see logging from the system and yours. Here is what I get
09-08 17:06:56.581 294-352/system_process V/BackupServiceBinder﹕ doBackup() invoked
09-08 17:06:56.591 294-352/system_process D/PerformBackupTask﹕ starting agent for backup of BackupRequest{pkg=android}
09-08 17:06:56.591 294-352/system_process D/BackupManagerService﹕ awaiting agent for ApplicationInfo{40d5efc0 android}
09-08 17:06:56.591 294-308/system_process D/BackupManagerService﹕ agentConnected pkg=android agent=android.app.backup.BackupAgent$BackupServiceBinder#4112a228
09-08 17:06:56.601 294-352/system_process V/BackupServiceBinder﹕ doBackup() invoked
09-08 17:06:56.601 294-352/system_process D/BackupHelperDispatcher﹕ handling existing helper 'wallpaper' android.app.backup.WallpaperBackupHelper#41149150
09-08 17:06:56.621 294-352/system_process D/PerformBackupTask﹕ starting agent for backup of BackupRequest{pkg=com.catglo.sellpr}
09-08 17:06:56.661 294-352/system_process D/BackupManagerService﹕ awaiting agent for ApplicationInfo{41074748 com.catglo.sellpr}
09-08 17:06:56.781 294-514/system_process D/BackupManagerService﹕ agentConnected pkg=com.catglo.sellpr agent=android.os.BinderProxy#410768c8
09-08 17:06:56.791 2263-2274/com.catglo.sellpr V/BackupServiceBinder﹕ doBackup() invoked
09-08 17:06:56.791 2263-2274/com.catglo.sellpr I/backup﹕ onBackup called
09-08 17:06:57.251 294-352/system_process I/PerformBackupTask﹕ Backup pass finished.
in the above log com.catglo.sellpr is from my app and the line that reads com.catglo.sellpr I/backup﹕ onBackup called is the log message in my code. For the onRestore I get
09-08 17:13:34.431 294-352/system_process D/BackupManagerService﹕ MSG_RUN_RESTORE observer=android.app.backup.IRestoreObserver$Stub$Proxy#413132c0
09-08 17:13:34.511 294-352/system_process V/BackupServiceBinder﹕ doRestore() invoked
09-08 17:13:34.561 294-352/system_process D/BackupManagerService﹕ awaiting agent for ApplicationInfo{41074748 com.catglo.sellpr}
09-08 17:13:34.561 294-427/system_process D/BackupManagerService﹕ agentConnected pkg=com.catglo.sellpr agent=android.os.BinderProxy#41127ee0
09-08 17:13:34.571 2263-2276/com.catglo.sellpr V/BackupServiceBinder﹕ doRestore() invoked
09-08 17:13:34.571 2263-2276/com.catglo.sellpr I/backup﹕ onRestore called
Earlier I had an exception in onBackup and my log from onRestore was never called but the system messages related to restore were.
The app will not Force Close because of an exception in the backup.
The spinning globe application unning on the emulator works on android 1.5 as target but puts out a "force close application" error in android 2.2 target. Where should i look to find the problem ?
I have enclosed the logcat details that I get,
D/MediaScanner( 183): prescan time: 4913ms
D/MediaScanner( 183): scan time: 693ms
D/MediaScanner( 183): postscan time: 45ms
D/MediaScanner( 183): total time: 5651ms
D/MediaScannerService( 183): done scanning volume internal
I/PackageManager( 67): Removing non-system package:com.android.SpinningGlobe
I/ActivityManager( 67): Force stopping package com.android.SpinningGlobe uid=10038
D/dalvikvm( 127): GC_EXPLICIT freed 12963 objects / 655936 bytes in 168ms
D/PackageManager( 67): Scanning package com.android.SpinningGlobe
I/PackageManager( 67): Package com.android.SpinningGlobe codePath changed from /data/app/com.android.SpinningGlobe-2.apk to /data/app/com.android.SpinningGlobe-1.apk; Retaining data and using new
I/PackageManager( 67): /data/app/com.android.SpinningGlobe-1.apk changed; unpacking
D/installd( 34): DexInv: --- BEGIN '/data/app/com.android.SpinningGlobe-1.apk' ---
D/dalvikvm( 255): DexOpt: load 214ms, verify 229ms, opt 5ms
D/installd( 34): DexInv: --- END '/data/app/com.android.SpinningGlobe-1.apk' success)---
W/PackageManager( 67): Code path for pkg : com.android.SpinningGlobe changing from /data/app/com.android.SpinningGlobe-2.apk to /data/app/com.android.SpinningGlobe-1.apk
W/PackageManager( 67): Resource path for pkg : com.android.SpinningGlobe changing from /data/app/com.android.SpinningGlobe-2.apk to /data/app/com.android.SpinningGlobe-1.apk
I/ActivityManager( 67): Force stopping package com.android.SpinningGlobe uid=10038
D/PackageManager( 67): Activities: com.android.SpinningGlobe.GLApp
I/installd( 34): move /data/dalvik-cache/data#app#com.android.SpinningGlobe-1.apk#classes.dex -> /data/dalvik-cache/data#app#com.android.SpinningGlobe-1.apk#classes.dex
D/PackageManager( 67): New package installed in /data/app/com.android.SpinningGlobe-1.apk
I/ActivityManager( 67): Force stopping package com.android.SpinningGlobe uid=10038
I/ActivityManager( 67): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=256 uid=10028 gids={}
D/dalvikvm( 167): GC_EXPLICIT freed 3943 objects / 244424 bytes in 1708ms
D/dalvikvm( 67): GC_EXPLICIT freed 7297 objects / 468432 bytes in 667ms
W/RecognitionManagerService( 67): no available voice recognition services found
I/ActivityThread( 256): Publishing provider com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
I/installd( 34): unlink /data/dalvik-cache/data#app#com.android.SpinningGlobe-2.apk#classes.dex
D/AndroidRuntime( 118): Shutting down VM
D/jdwp ( 118): adbd disconnected
I/AndroidRuntime( 118): NOTE: attach of thread 'Binder Thread #3' failed
D/AndroidRuntime( 266):
D/AndroidRuntime( 266): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime( 266): CheckJNI is ON
D/AndroidRuntime( 266): --- registering native functions ---
I/ActivityManager( 67): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.android.SpinningGlobe/.GLApp }
D/AndroidRuntime( 266): Shutting down VM
D/jdwp ( 266): adbd disconnected
I/AndroidRuntime( 266): NOTE: attach of thread 'Binder Thread #3' failed
I/ActivityManager( 67): Start proc com.android.SpinningGlobe for activity com.android.SpinningGlobe/.GLApp: pid=273 uid=10038 gids={1015}
I/ARMAssembler( 67): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x32b4a0:0x32b5ac] in 3627836 ns
D/libEGL ( 273): egl.cfg not found, using default config
D/libEGL ( 273): loaded /system/lib/egl/libGLES_android.so
D/dalvikvm( 273): GC_EXTERNAL_ALLOC freed 839 objects / 59328 bytes in 151ms
W/dalvikvm( 273): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
I/ActivityManager( 67): Displayed activity com.android.SpinningGlobe/.GLApp: 4870 ms (total 4870 ms)
E/AndroidRuntime( 273): FATAL EXCEPTION: GLThread 8
E/AndroidRuntime( 273): java.lang.IndexOutOfBoundsException
E/AndroidRuntime( 273): at java.nio.IntArrayBuffer.get(IntArrayBuffer.java:63)
E/AndroidRuntime( 273): at com.android.SpinningGlobe.GLRenderer.onDrawFrame(GLRenderer.java:105)
E/AndroidRuntime( 273): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
E/AndroidRuntime( 273): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
W/ActivityManager( 67): Force finishing activity com.android.SpinningGlobe/.GLApp
I/ARMAssembler( 67): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x33f9a8:0x33fa64] in 1258819 ns
Any insights on where the problem could be ?
You should look at the log from the emulator.
You can get this on the command line using:
adb logcat
Or if you're using the ADT Plugin for Eclipse the log is visible there. If you can't see it select Window ▶ Show View ▶ Other... and then select Android ▶ LogCat.
It's probably also worth reading the Debugging page in the Android Developer Documentation.
Recompile it under 2.2 and look for deprecated warnings