Android adb - Transfert d'application apk split

Source : https://raccoon.onyxbits.de/blog/install-split-apk-adb/

Récupération des APK sur le 1er smartphone

mkdir -p ~/tmp/apk cd ~/tmp/apk

$ adb shell pm list packages |grep heavn
package:/data/app/app.heavn-1/base.apk
package:/data/app/app.heavn-1/split_config.armeabi_v7a.apk
package:/data/app/app.heavn-1/split_config.fr.apk
package:/data/app/app.heavn-1/split_config.xxxhdpi.apk

adb pull /data/app/app.heavn-1/base.apk ~/tmp/apk/ adb pull data/app/app.heavn-1/split_config.armeabi_v7a.apk ~/tmp/apk/ adb pull /data/app/app.heavn-1/split_config.fr.apk ~/tmp/apk/ adb pull /data/app/app.heavn-1/split_config.xxxhdpi.apk ~/tmp/apk/

Nous aurons besoin de connaître la taille de ces fichiers

$ du -c *.apk
14676 base.apk
7044 split_config.armeabi_v7a.apk
32 split_config.fr.apk
104 split_config.xxxhdpi.apk
21856 total

Connexion au second smartphone

adb push *.apk /sdcard/Download
adb shell cd /sdcard/Download

## pm install-create -S [TOTAL_SIZE_OF_ALL_APKS]
$ pm install-create -S 21856
Success: created install session [2146766274]
## pm install-write -S APK_SIZE SESSION_ID INDEX PATH
$ pm install-write -S 14676 1373617958 0 base.apk
System server has no access to read file context u:object_r:sdcardfs:s0 (from path /storage/emulated/0/Download/base.apk, context u:r:system_server:s0)
Error: Unable to open file: base.apk
Consider using a file under /data/local/tmp/

mv /sdcard/Download/*.apk /data/local/tmp/ cd /data/local/tmp/ pm install-write -S 14676 1373617958 0 base.apk pm install-write -S 7044 1373617958 1 split_config.armeabi_v7a.apk pm install-write -S 32 1373617958 2 split_config.fr.apk pm install-write -S 104 1373617958 3 split_config.xxxhdpi.apk pm install-commit 1373617958