Situation. I have a .img disk image file obtained from a .vmdk file via a virtualbox conversion, the latter being created by an Android 4.4.2 emulator. I'm trying to recover some app data and transfer it to a new, working, .img file.

What I did. I extracted APKs and copied app data folders (com.devname.appname) from/to the /data/data directory. I did that using a file manager and via Ubuntu terminal. I also attempted to copy the folders to /Android/data. Although cp -ar retains files permissions and ownership, that was of no use after the import into the working image.

The problem (and a workaround). When the APKs are installed, a new uid (in the 10000 group) is generated for them. These values are unknown when I import the data folders, hence they are destroyed at phone boot. A log in /data/system/uiderrors.txt confirms this. The only way I could make it work was to install the APK, run the app so that the new data folders are created with a proper uid, replace those folders with old ones and fix ownership and permissions accordingly (for every app). This turned out to be effective, but it's a very tedious and error-prone process.

Is there a proper way to achieve this result?

Probably noteworthy:

  • Folders are copied after the APK is installed. The APK won't install if folders are there already.
  • Original image has some Android data corrupted, so it cannot be mounted in the emulator. loop mount works properly, though.
  • I didn't modify packages.list and packages.xml files (should I?).
  • This problem exists even for popular/common backup-restore apps such as Titanium Backup; I know of no way to rectify it. +1 and would like to see a solution as well. It would be of less significance after Android 8.x though - now the name of APK folders are hashed too so you can't figure that part out either. – Andy Yan Aug 11 '18 at 1:12
  • Thanks. I wasn't aware of that change in Oreo, good to know. I was also wondering how backup apps and ADB backup/restore commands handle file permissions. – s.kudo Aug 11 '18 at 22:21

Your Answer

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

Browse other questions tagged or ask your own question.