Android Studio: adb – INSTALL_FAILED_INSUFFICIENT_STORAGE

setevoy

Arseny Zinchenko

Posted on March 4, 2019

Android Studio: adb – INSTALL_FAILED_INSUFFICIENT_STORAGE

Proceeding fighting with our UI auto-tests 🙂

Two previous posts were really useful this time – Android Studio: установка на Linux и работа с Android Virtual Devices and Appium: Android Virtual Device, Original error: Condition unmet after 60159 ms и костыль.

In general – tests works fine but sometimes gives me interesting issues.

This time out QA-engineer sent me the new error to our Slack:

[debug] [W3C] Encountered internal error running command: Error executing adbExec. Original error: 'Command '/android/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r -g /home/projectname/projectnameMenBuilds/projectnameMen-stage.apk' exited with code 1'; Stderr: 'adb: failed to install /home/projectname/projectnameMenBuilds/projectnameMen-stage.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]'; Code: '1'
[debug] [W3C] Error: Command '/android/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r -g /home/projectname/projectnameBuilds/projectnameMen-stage.apk' exited with code 1
[debug] [W3C]     at ChildProcess.proc.on.code (/home/projectname/node_modules/teen_process/lib/exec.js:94:19)
[debug] [W3C]     at emitTwo (events.js:126:13)
[debug] [W3C]     at ChildProcess.emit (events.js:214:7)
[debug] [W3C]     at maybeClose (internal/child_process.js:925:16)
[debug] [W3C]     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
[HTTP] <-- POST /wd/hub/session 500 2312 ms - 1165
[HTTP]
[HTTP] --> POST /wd/hub/session
[HTTP]

The first conspicuous message – “Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]’; Code: ‘1’“.

On the first Google request with the “android INSTALL_FAILED_INSUFFICIENT_STORAGE” I found this>>> question on the StackOverflow and one answer there, describing almost the same issue – here>>>.

Let’s check.

Run the emulator used in tests:

projectname@projectname-ci:~$ emulator -avd Nexus_5X_API_26

Run shell in there:

projectname@projectname-ci:~$ adb shell
generic_x86:/ $

Check available space:

1|generic_x86:/ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          611M  4.6M  606M   1% /
tmpfs           756M  488K  756M   1% /dev
/dev/block/vda1 2.4G  1.4G  0.9G  59% /system
/dev/block/vde1  90M   35M   53M  40% /vendor
tmpfs           756M     0  756M   0% /mnt
/dev/block/vdb   61M   56K   60M   1% /cache
/dev/block/dm-0 1.9G  1.7G  148M  93% /data
/data/media     1.9G  1.7G  148M  93% /storage/emulated

148M 93% /data – 148 MB, obviously not too much.

Haven’t looked at the apk-file with our application used, but anyway – too low free space.

Try to check the /data content:

1|generic_x86:/ $ ls -l /data/
ls: /data/: Permission denied

Aha…

Try with the root:

projectname@projectname-ci:~$ adb root
adbd cannot run as root in production builds

Well – okay. There are solutions about how to get root access – but I don’t want to waste time now for it.

Just will increase disk used for this device – there is enough available space on the build-host.

Next Google search with the “android emulator disk space“, led me to the Quick Tip: Increase the storage size of your Android Emulator post.

Find device’s directory used:

projectname@projectname-ci:~$ ls -l ~/.android/avd/
total 16
drwxrwxr-x 5 projectname projectname 4096 бер  4 11:35 Nexus_5X_API_26.avd
-rw-rw-r-- 1 projectname projectname  127 лис 20 17:50 Nexus_5X_API_26.ini
drwxrwxr-x 4 projectname projectname 4096 гру 18 18:44 test.avd
-rw-rw-r-- 1 projectname projectname  105 лис 19 17:18 test.ini

And the ~/.android/avd/Nexus_5X_API_26.avd:

projectname@projectname-ci:~$ ls -la ~/.android/avd/Nexus_5X_API_26.avd/
total 2861472
drwxrwxr-x 5 projectname projectname       4096 бер  4 11:35 .
drwxrwxr-x 4 projectname projectname       4096 бер  4 11:41 ..
-rw-rw-r-- 1 projectname projectname         96 бер  4 11:35 AVD.conf
-rw-r--r-- 1 projectname projectname   69206016 бер 12  2018 cache.img
-rw-r--r-- 1 projectname projectname   42598400 бер  4 11:35 cache.img.qcow2
-rw-rw-r-- 1 projectname projectname       1173 лют 14 11:10 config.ini

Here is the config.ini mentioned in the post above:

projectname@projectname-ci:~$ cat ~/.android/avd/Nexus_5X_API_26.avd/config.ini | grep data
disk.dataPartition.size=2G

Set a new value here, let’s say – 5 GB:

...
disk.dataPartition.size=5G
...

Run an emulator again:

projectname@projectname-ci:~$ emulator -avd Nexus_5X_API_26
emulator: WARNING: userdata partition is resized from 2048 M to 5120 M

Shell:

projectname@projectname-ci:~$ adb shell
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.

Er… Okay – kill theavd:

projectname@projectname-ci:~$ adb kill-server

And shell again:

projectname@projectname-ci:~$ adb shell
* daemon not running; starting now at tcp:5037
* daemon started successfully

Check disk space now:

generic_x86:/ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          611M  4.6M  606M   1% /
tmpfs           756M  488K  756M   1% /dev
/dev/block/vda1 2.4G  1.4G  0.9G  59% /system
/dev/block/vde1  90M   35M   53M  40% /vendor
tmpfs           756M     0  756M   0% /mnt
/dev/block/vdb   61M   56K   60M   1% /cache
/dev/block/dm-0 4.8G   88M  4.7G   2% /data
/data/media     4.8G   88M  4.7G   2% /storage/emulated

Run tests – and everything works now.

Similar posts

💖 💪 🙅 🚩
setevoy
Arseny Zinchenko

Posted on March 4, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related