1

Edits and logcats below.

What Happenned:

A few days back it left my phone (Mediatek chipset) to charge overnight. What I did not notice was that the charger was loose and the charge was at around 2%. Next morning I woke up to find my phone's battery drained completely.

When I tried to start it (after charging), it was taking a bit too much time, and the phone was heating up. However the boot didn't complete nor did the phone reboot (like a bootloop).

What I Did:

I went to the recovery, took backups and cleared the /data partition and got the phone to start. However I require the application data (more than the phone) and just formatting the partition didn't seem to take me closer to my goal and hence I restored the backups.

I then cleared the data of several programs which might have caused the problem:

rm -rf com.android.captiveportallogin com.android.carrierconfig com.android.cellbroadcastreceiver com.android.certinstaller com.android.defcontainer com.android.development com.android.documentsui com.android.externalstorage com.android.frameworks.telresources com.android.keychain com.android.managedprovisioning com.android.mms.service com.android.noisefield com.android.pacprocessor com.android.printspooler com.android.proxyhandler com.android.server.telecom com.android.statementservice com.android.stk com.android.vpndialogs com.android.webview com.gametion.ludo com.google.android.configupdater com.grarak.kerneladiutor com.jrummy.app.managerfree com.lexa.fakegps com.makeinfo.androididchanger com.one24.deviceid com.ores.hash com.phoneinfo.changer com.resurrection.otacom.sanctuaire.netswisstool com.unique.mobilefaker com.zimperium.zanti cyanogenmod.platform de.robv.android.xposed.installer it.evilsocket.dsploit net.fidanov.landroid org.cyanogenmod.livelockscreen.service org.cyanogenmod.providers.datausage
rm -rf org.cyanogenmod.snap org.cyanogenmod.theme.chooser org.cyanogenmod.themes.provider org.cyanogenmod.wallpapers.photophase org.cyanogenmod.weather.provider org.omnirom.omniswitch tursky.jan.settings
rm -rf com.android.settings com.android.systemui

Didn't help...

So I accessed logcat and extracted some of the possibly juicy bits (in random order):

page record for 0xb6e4301c was not found
AndroidRuntime:        at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:1873)
ServiceManager: service 'batterystats' died
01-01 07:33:29.583  8300  8300 D AndroidRuntime: Shutting down VM
01-01 07:33:29.584  8300  8300 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
01-01 07:37:16.064 15437 15437 E AndroidRuntime: Error reporting crash
01-01 07:37:16.064 15437 15437 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.IActivityManager.handleApplicationCrash(android.os.IBinder, android.app.ApplicationErrorReport$CrashInfo)' on a null object reference
01-01 07:37:16.064 15437 15437 I Process : Sending signal. PID: 15437 SIG: 9
01-01 07:37:16.088   189   189 I ServiceManager: service 'batterystats' died
01-01 07:37:16.088   189   189 I ServiceManager: service 'appops' died
01-01 07:37:16.088   189   189 I ServiceManager: service 'power' died
01-01 07:37:16.088   189   189 I ServiceManager: service 'display' died
01-01 07:37:16.093   217   217 E installd: eof
01-01 07:37:16.093   217   217 E installd: failed to read size
01-01 07:37:16.093   217   217 I installd: closing connection
01-01 07:37:16.404 12127 12127 I Zygote  : Process 12239 exited cleanly (13)
01-01 07:37:16.405 12127 12127 E Zygote  : Exit zygote because system server (15437) has terminated
01-01 07:37:16.446   189   189 I ServiceManager: service 'user.xposed.app' died
01-01 07:37:16.453   189   189 I ServiceManager: service 'media.audio_flinger' died
01-01 07:37:16.453   189   189 I ServiceManager: service 'media.player' died
01-01 07:37:16.453   189   189 I ServiceManager: service 'media.resource_manager' died
01-01 07:37:35.780 17500 17500 E cutils-trace: Error opening trace file: No such file or directory (2)
01-01 07:32:20.048  3896  3896 E AndroidRuntime: Error reporting WTF
01-01 07:32:20.048  3896  3896 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.app.IActivityManager.handleApplicationWtf(android.os.IBinder, java.lang.String, boolean, android.app.ApplicationErrorReport$CrashInfo)' on a null object reference
01-01 07:32:20.048  3896  3896 E AndroidRuntime:        at com.android.internal.os.RuntimeInit.wtf(RuntimeInit.java:353)
01-01 07:32:20.048  3896  3896 E AndroidRuntime:        at android.util.Log$1.onTerribleFailure(Log.java:104)
01-01 07:32:20.048  3896  3896 E AndroidRuntime:        at android.util.Log.wtf(Log.java:297)
01-01 07:32:20.048  3896  3896 E AndroidRuntime:        at android.util.Slog.wtf(Slog.java:82)
01-01 07:32:41.126  5786  5786 E AndroidRuntime: android.util.Log$TerribleFailure: No start tag found in package manager settings
01-01 07:32:41.161  5786  5786 W PackageManager: Library not found: /system/framework/org.apache.http.legacy.jar
01-01 07:32:41.247  5786  5786 E System  : ******************************************
01-01 07:32:41.249  5786  5786 E System  : ************ Failure starting system services
01-01 07:32:41.249  5786  5786 E System  : java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.android.server.pm.Settings$VersionInfo.fingerprint' on a null object reference

Then I got an idea and did rm -rf /data/data and mkdir /data/data. Didn't help but showed that the problem was not due to app data but something else in the data partition.

Soon, I noticed a repeating pattern in logcat, indicating my phone was stuck in a loop (not bootloop) and not a blocking call to a process or thread.

The looping logcat:

01-01 07:32:53.191  6368  6368 E System  : ******************************************
01-01 07:32:53.191  6368  6368 E System  : ************ Failure starting system services
01-01 07:32:53.191  6368  6368 E System  : java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.android.server.pm.Settings$VersionInfo.fingerprint' on a null object reference
01-01 07:32:53.191  6368  6368 E System  :      at com.android.server.pm.PackageManagerService.<init>(PackageManagerService.java:2170)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:1873)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:387)
01-01 07:32:53.191  6368  6368 E System  :      at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
01-01 07:32:53.191  6368  6368 E System  :      at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.server.SystemServer.startBootstrapServices(<Xposed>)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.server.SystemServer.run(SystemServer.java:289)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.server.SystemServer.main(SystemServer.java:176)
01-01 07:32:53.191  6368  6368 E System  :      at java.lang.reflect.Method.invoke(Native Method)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-01 07:32:53.191  6368  6368 E System  :      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-01 07:32:53.191  6368  6368 E System  :      at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
01-01 07:32:53.192  6368  6368 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
01-01 07:32:53.192  6368  6368 E AndroidRuntime: java.lang.NullPointerException: Attempt to read from field 'java.lang.String com.android.server.pm.Settings$VersionInfo.fingerprint' on a null object reference
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.server.pm.PackageManagerService.<init>(PackageManagerService.java:2170)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:1873)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:387)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.server.SystemServer.startBootstrapServices(<Xposed>)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.server.SystemServer.run(SystemServer.java:289)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.server.SystemServer.main(SystemServer.java:176)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-01 07:32:53.192  6368  6368 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
01-01 07:32:53.193  6368  6368 E AndroidRuntime: Error reporting crash
01-01 07:32:53.193  6368  6368 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'void android.app.IActivityManager.handleApplicationCrash(android.os.IBinder, android.app.ApplicationErrorReport$CrashInfo)' on a null object reference
01-01 07:32:53.193  6368  6368 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:95)
01-01 07:32:53.193  6368  6368 E AndroidRuntime:        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
01-01 07:32:53.193  6368  6368 E AndroidRuntime:        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
01-01 07:32:53.411  6438  6438 F libc    : page record for 0xb6d8301c was not found (block_size=16)
01-01 07:32:57.925  6682  6682 F libc    : page record for 0xb6e5b01c was not found (block_size=16)
01-01 07:33:03.304  6930  6930 F libc    : page record for 0xb6de901c was not found (block_size=16)
01-01 07:33:05.758  7050  7050 I InstallerConnection: connecting...
01-01 07:33:05.772  7050  7050 I InstallerConnection: disconnecting...
01-01 07:33:05.790  7050  7050 I SystemServer: Entered the Android system server!
01-01 07:33:05.896  7050  7050 I SystemServiceManager: Starting com.android.server.pm.Installer
01-01 07:33:05.897  7050  7050 I Installer: Waiting for installd to be ready.
01-01 07:33:05.897  7050  7050 I InstallerConnection: connecting...
01-01 07:33:05.897  7050  7050 I SystemServiceManager: Starting com.android.server.am.ActivityManagerService$Lifecycle
01-01 07:33:05.908  7050  7050 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:05.908  7050  7050 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:05.908  7050  7050 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:05.908  7050  7050 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:05.908  7050  7050 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:05.908  7050  7050 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:06.027  7050  7050 I ActivityManager: Memory class: 96
01-01 07:33:06.101  7050  7050 D BatteryStatsImpl: Reading daily items from /data/system/batterystats-daily.xml
01-01 07:33:06.254  7050  7050 W ProcessCpuTracker: Skipping unknown process pid 7075
01-01 07:33:06.265  7050  7050 I IntentFirewall: Read new rules (A:0 B:0 S:0)
01-01 07:33:06.279  7050  7050 D AppOps  : AppOpsService published
01-01 07:33:06.279  7050  7050 I SystemServiceManager: Starting com.android.server.power.PowerManagerService
01-01 07:33:06.287  7050  7050 I SystemServiceManager: Starting com.android.server.lights.LightsService
01-01 07:33:06.290  7050  7050 I SystemServiceManager: Starting com.android.server.display.DisplayManagerService
01-01 07:33:06.293  7050  7050 I SystemServiceManager: Starting phase 100
01-01 07:33:06.301  7050  7094 I DisplayManagerService: Display device added: DisplayDeviceInfo{"Built-in Screen": uniqueId="local:0", 720 x 1280, modeId 1, defaultModeId 1, supportedModes [{id=1, width=720, height=1280, fps=55.9}], colorTransformId 1, defaultColorTransformId 1, supportedColorTransforms [{id=1, colorTransform=0}], density 320, 294.967 x 295.563 dpi, appVsyncOff 0, presDeadline 18889087, touch INTERNAL, rotation 0, type BUILT_IN, state UNKNOWN, FLAG_DEFAULT_DISPLAY, FLAG_ROTATES_WITH_CONTENT, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}
01-01 07:33:06.304  7050  7050 I SystemServer: Package Manager
01-01 07:33:06.309  7050  7094 I DisplayManagerService: Display device changed state: "Built-in Screen", ON
01-01 07:33:08.137  7201  7201 F libc    : page record for 0xb6e5701c was not found (block_size=16)
01-01 07:33:13.103  7467  7467 F libc    : page record for 0xb6de801c was not found (block_size=16)
01-01 07:33:17.544  7700  7700 I InstallerConnection: connecting...
01-01 07:33:17.552  7700  7700 I InstallerConnection: disconnecting...
01-01 07:33:17.579  7700  7700 I SystemServer: Entered the Android system server!
01-01 07:33:17.750  7700  7700 I SystemServiceManager: Starting com.android.server.pm.Installer
01-01 07:33:17.750  7700  7700 I Installer: Waiting for installd to be ready.
01-01 07:33:17.750  7700  7700 I InstallerConnection: connecting...
01-01 07:33:17.751  7700  7700 I SystemServiceManager: Starting com.android.server.am.ActivityManagerService$Lifecycle
01-01 07:33:17.760  7700  7700 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:17.760  7700  7700 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:17.760  7700  7700 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:17.760  7700  7700 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:17.760  7700  7700 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:17.760  7700  7700 I XXXXXX  : choosing minFree values for 32 Bit
01-01 07:33:17.836  7700  7700 I ActivityManager: Memory class: 96
01-01 07:33:17.914  7700  7700 D BatteryStatsImpl: Reading daily items from /data/system/batterystats-daily.xml
01-01 07:33:18.187  7700  7700 W ProcessCpuTracker: Skipping unknown process pid 7732
01-01 07:33:18.196  7700  7700 I IntentFirewall: Read new rules (A:0 B:0 S:0)
01-01 07:33:18.333  7700  7700 D AppOps  : AppOpsService published
01-01 07:33:18.334  7700  7700 I SystemServiceManager: Starting com.android.server.power.PowerManagerService
01-01 07:33:18.353  7700  7700 I SystemServiceManager: Starting com.android.server.lights.LightsService
01-01 07:33:18.356  7700  7700 I SystemServiceManager: Starting com.android.server.display.DisplayManagerService
01-01 07:33:18.370  7700  7761 I DisplayManagerService: Display device added: DisplayDeviceInfo{"Built-in Screen": uniqueId="local:0", 720 x 1280, modeId 1, defaultModeId 1, supportedModes [{id=1, width=720, height=1280, fps=55.9}], colorTransformId 1, defaultColorTransformId 1, supportedColorTransforms [{id=1, colorTransform=0}], density 320, 294.967 x 295.563 dpi, appVsyncOff 0, presDeadline 18889087, touch INTERNAL, rotation 0, type BUILT_IN, state UNKNOWN, FLAG_DEFAULT_DISPLAY, FLAG_ROTATES_WITH_CONTENT, FLAG_SECURE, FLAG_SUPPORTS_PROTECTED_BUFFERS}
01-01 07:33:18.373  7700  7700 I SystemServiceManager: Starting phase 100
01-01 07:33:18.374  7700  7761 I DisplayManagerService: Display device changed state: "Built-in Screen", ON
01-01 07:33:18.375  7700  7700 I SystemServer: Package Manager
01-01 07:33:18.496  7700  7700 D SELinuxMMAC: Using policy file /system/etc/security/mac_permissions.xml
01-01 07:33:18.504  7700  7700 W PackageManager: No start tag found in package manager settings
01-01 07:33:18.507  7700  7700 E PackageManager: No start tag found in package manager settings
01-01 07:33:18.509  7700  7700 E AndroidRuntime: Error reporting WTF
01-01 07:33:18.509  7700  7700 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.app.IActivityManager.handleApplicationWtf(android.os.IBinder, java.lang.String, boolean, android.app.ApplicationErrorReport$CrashInfo)' on a null object reference
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.internal.os.RuntimeInit.wtf(RuntimeInit.java:353)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at android.util.Log$1.onTerribleFailure(Log.java:104)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at android.util.Log.wtf(Log.java:297)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at android.util.Slog.wtf(Slog.java:82)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.pm.Settings.readLPw(Settings.java:2829)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.pm.PackageManagerService.<init>(PackageManagerService.java:2030)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:1873)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:387)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.startBootstrapServices(<Xposed>)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.run(SystemServer.java:289)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.main(SystemServer.java:176)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
01-01 07:33:18.509  7700  7700 E AndroidRuntime: Original WTF:
01-01 07:33:18.509  7700  7700 E AndroidRuntime: android.util.Log$TerribleFailure: No start tag found in package manager settings
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at android.util.Log.wtf(Log.java:291)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at android.util.Slog.wtf(Slog.java:82)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.pm.Settings.readLPw(Settings.java:2829)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.pm.PackageManagerService.<init>(PackageManagerService.java:2030)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:1873)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:387)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.startBootstrapServices(<Xposed>)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.run(SystemServer.java:289)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.server.SystemServer.main(SystemServer.java:176)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-01 07:33:18.509  7700  7700 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
01-01 07:33:18.527  7700  7700 W PackageManager: Library not found: /system/framework/org.apache.http.legacy.jar
01-01 07:33:18.580  7700  7700 E System  : ******************************************
01-01 07:33:18.581  7700  7700 E System  : ************ Failure starting system services

Note tha the first and last 2 lines are the same, indicating a loop.

Edit:
/data/system # rm -rf * helps starts the phone, so the problen is there. But running the command results in a partial loss of the application data (so I restored the backups of the faulty /data partition).

  • Both referenced Xposed - try disabling it temporarily by mashing the volume buttons when first booting up. Also, try just flashing your original ROM again on top of the existing installation - sounds stupid but actually worked for me in a similar situation. – Andy Yan Sep 16 '16 at 0:50
  • Done, not helping... – sbrm1 Sep 22 '16 at 15:15
  • And I'll try the ROM thing tonight. – sbrm1 Sep 22 '16 at 15:16
5

I just came across this problem myself on my Nexus 5 running Android 6 and after tinkering with it for a few days I was able to resolve it without wiping all my data, so I wanted to share what I did in case anyone else ever comes across a similar issue and is up for the challenge of debugging the issue instead of wiping the phone.

My problems all seemed to have the same root cause: empty XML files. I had played around with disabling fsync in my kernel to try out the performance difference, and this probably caused some data loss.

Observation: /data/system/packages.xml, /data/system/packages.list and /data/system/job/jobs.xml were empty.

Below are the steps I executed. Be aware, this is the result of experimentation and you shouldn't blindly execute these commands without understanding them first. ;)

  • Back up the entire /data partition.
  • Delete the /data/system directory and reboot to regenerate it.
  • Copy the /data/system directory somewhere (in my case: /sdcard/system-good).
  • Restore the backup of the /data partition, restoring erased app data.
  • Delete the JobStore file: rm /data/system/job/jobs.xml
  • Copy the regenerated files:
    cat /sdcard/system-good/packages.list > /data/system/packages.list
    cat /sdcard/system-good/packages.xml > /data/system/packages.xml
  • Fix package UID's based on the error logs:
    grep "has changed from uid" /sdcard/system-good/uiderrors.txt | while read -r LINE; do sed -i "s/\(^$(echo "$LINE" | awk '{ printf "%s\\) %d/\\1 %d", $6, $13, $11 }')/" /data/system/packages.list ; done
    grep "has changed from uid" /sdcard/system-good/uiderrors.txt | while read -r LINE; do sed -i "s/\(^ <package name=\"$(echo "$LINE" | awk '{ printf "%s\" .\\+ userId=\"\\)%d\">/\\1%d\">", $6, $13, $11 }')/" /data/system/packages.xml ; done
  • Wiped cache and dalvik for good measure.
  • Rebooted and my Android including all my apps were revived!

For me this turned into bit of a side project, and I learned a bit more about Android internals. :) Not all my steps may be relevant to resolve your scenario.

The empty jobs.xml caused a NullPointerException in the JobStore: java.lang.RuntimeException: Failed to create service com.android.server.job.JobSchedulerService: service constructor threw an exception. It has already been fixed upstream, but that fix is not yet included in Android 6. Just deleting /data/system/job/jobs.xml skips the entire code section with the bug, resolving the issue.

The empty package manager files should regenerate upon deletion, however that unfortunately resulted in another bootloop for me, for which I was unable to collect logs to further assess the problem. So I recovered the system by deleting the entire /data/system, then made a copy of it and restored my backup of /data, and then diff'ed the old and the new version of /data/system to figure out what could be causing the crash.

In my case the major difference was that the UID's for all my apps had changed in the regenerated package.xml and package.list files, causing the package manager to delete all data for those apps upon checking package contents during boot. I resolved this by copying the regenerated versions and changing the them to match the old UID's, using the logfile which recorded all mismatched UID's. Not pretty, and in hindsight it might have been better to just read the UID's from the /data/data directories or look into how Android does this regeneration in the first place and tweak that, but this worked as well.

  • Thanks for posting your solution., Unclean shutdowns will cause the /data/system/packges files to reset to empty files, If android would have keep backup or journal for those files it would be great. – Erb Feb 22 '18 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.