Error when trying to install second flutter app on the emulator

Viewed 44926

I created a simple flutter app and run it on android emulator. It worked Ok. Now I created another one and when I'm trying to run it on the emulator I'm getting:

 Error: ADB exited with exit code 1
adb: failed to install /Users/Admin/Development/flutter/flutter_app_test/build/app/outputs/apk/app.apk: Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]
Error launching application on Android SDK built for x86.

Once I delete the first app from emulator I'm able to install the second one and run it successfully.

So anytime I have one flutter app installed on the emulator installing another one will lead to the same error.

Is there a way to overcome this limitation? Or this is a bug?

9 Answers

You probably configures storage too small and you get this error when the emulator runs out of storage when you install.

Either modify the emulator configuration or uninstall before you install another app.

Open the Android Virtual Device (AVD) manager in Android Studio, edit the emulator and increase "Internal Storage" and restart the emulator.

On android studio

  1. Tools > AVD Manager
  2. Edit the virtual device
  3. Show advanced settings
  4. Increase internal storage

internal storage

Free-up the space

free space used by emulators / virtual devices

  1. Open Android Studio
  2. Tools > AVD Manager
  3. click menu icon on right side of emulator / virtual device
  4. select Wipe Data
  5. select Yes

There you'll see the space will be free up.

For clarity see the below image, 3+ GB space is freed to 1.0 GB.

enter image description here

Check Free Space on Emulator - adb shell

Your Android Emulator must be running for this to work.

Open a Windows Command Prompt / Mac Terminal.

Go to the directory of the adb.exe program. (Not necessary if you have this in your PATH.)

On Windows (example location):

cd c:\Android\Sdk\platform-tools\

If you only have one running emulator, you don't need to specify which to connect via adb shell, so just run:

adb shell

If you have multiple emulators, you can specify which one after finding the name using

adb devices shows running emulators

enter image description here

Connect to the emulator

adb -s emulator-5554 shell

You'll be presented with a shell prompt inside emulator:

enter image description here

You'll have limited permissions, so switch user to root with command:

su

Use the disk filesystem command to see disk usage & available space

df

enter image description here

If you're running out of space, the Use% on /data will be high. You need to free up space on /data

Free up space by deleting apps you've installed...

Delete Apps in adb shell

Your apps are found in /data/data:

cd /data/data

It's easier to see your apps by reversing the directory listing sort order so your apps will show at bottom:

ls -ltr

enter image description here

You can delete your app directly here using rm -r. In the above example the app is stored under com.mobdev.user_interface_intro:

rm -r /data/data/com.mobdev.user_interface_intro

Repeat for any other apps you want to delete from the emulator to free up space.

Delete App in Emulator

You can also delete the app within the running emulator itself. Click on the Square button > Android Settings (Gear Icon)

Square button > Gear Icon

Click on Apps & Notifications

enter image description here

Find and click on your app

enter image description here

Click on Uninstall

enter image description here

Repeat as necessary for other apps you want to uninstall to free up emulator space.

  1. Open AVD Manager
  2. Wipe Data (delete datas from emulator)
  3. Open emulator
  4. Try to run app

I had the same problem after running the emulator multiple times on multiple projects. I deleted a 'qcow2' file and now the emulator runs peftectly so far at least.

C:\Users\admin \ .android\avd\test_avd_29.avd\userdata-qemu.img.qcow2

when I opened the file I saw that this file was like 1 milion KBytes and it seemed strange to me so I deleted it to see if this will fix the problem and it did.

i run into this problem already several times. What I usually do, I open the terminal and first run flutter clean to clean all unnecessary stuff (build, dart_tool, etc.) and afterwards I run a flutter pub get to get the all the dependencies back in.

I deleted some apps from the emulator and it didn't work.

But then I restarted the emulator and it worked.

For me it did not work to edit the emulator and increase "Internal Storage" and restart the emulator.

This is what worked for me:

  1. Open AVD Manager
  2. Delete your current Android device (I deleted all my devices)
  3. Add a new device (I added one with 32Gb internal storage)
Related