3

Some time ago I had trouble with my Huawei P30 and ADB/Android Studio installing APKs. It turned out I was using outdated versions of the libraries/tools. Got it resolved and happily moved on.

Now that my phone has upgraded to Android 10, I'm facing an issue very similar to the one before, but I cannot seem to fix it the same way (by updating libraries). I've tried installing multiple version of each tool, doing a clean install of Android Studio and the Android related tools, but nothing seems to help.

Android Studio

The current behavior is that Android Studio generates the APK only to later get indefinitely stuck at the "installing" step. On some small percentage of tests it fails.

ADB

I've also tried installing the APK from the command line using adb, but I get mixed results.

$ adb version
Android Debug Bridge version 1.0.41
Version 30.0.4-6686687

While Android Studio is running, installing the app either ends up failing, or hanging indefinitely just like in Android Studio:

$ cd .../platform-tools

$ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully

$ adb install C:\...\example.apk
Performing Streamed Install
adb: failed to install C:\...\example.apk

$ adb install C:\...\example.apk
Performing Streamed Install

^^^ Hangs there forever

Now, here is where things get interesting, if I close Android Studio, installing the APK results in successful installations about 50% of the time (the other half it fails and restarts the phone connection):

$ cd .../platform-tools

$ adb kill-server

$ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully

$ adb install C:\...\example.apk
Performing Streamed Install
adb: failed to install C:\...\example.apk

$ adb kill-server

$ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully

$ adb install C:\...\example.apk
Performing Streamed Install
Success

$ adb kill-server

$ adb install C:\...\example.apk
* daemon not running; starting now at tcp:5037
* daemon started successfully
Performing Streamed Install
Success

$ adb kill-server

$ adb install C:\...\example.apk
* daemon not running; starting now at tcp:5037
* daemon started successfully
Perform
adb: failed to install C:\...\example.apk

I have no trouble performing other actions, like pushing files into the phone or uninstalling apps. So far the issue is only related to installing APKs:

$ adb shell pm uninstall com.example
Success

$ adb push C:\...\app-debug.apk /sdcard/APKs
C:\Dropbox...\app-debug.apk: 1 file pushed, 0 skipped. 15.2 MB/s (31131771 bytes in 1.956s)

Why is it that installing an app fails or succeeds as if flipping a coin? Could this be a driver issue? How could Android Studio be interfering with the success rate of running the adb tool separately?

cavpollo
  • 4,071
  • 2
  • 40
  • 64
  • Were you able to find a solution to this? – Prethia Jan 28 '21 at 09:20
  • @Prethia not yet, unfortunately. – cavpollo Feb 01 '21 at 15:30
  • In my case, I was waiting for anim complete event of emulator in my jenkins builds, but apparently that wasn't enough. I could consistently install app while I used a sleep statement of 15 minutes which is terrible to say the least, I will post an answer to try to help this – Prethia Feb 01 '21 at 17:22

5 Answers5

3

Try to install your application with ./gradlew installDebug . It will probably give the reason of the failure

You can also make use of Android's Studio UI:

Gradle UI

cavpollo
  • 4,071
  • 2
  • 40
  • 64
Prethia
  • 1,183
  • 3
  • 11
  • 26
  • This is a nice solution! =) Not only is it more reliable than running the `adb` commands manually, but it is quite handy to run from Android Studio's Gradle UI. I did not get any errors, nevertheless I'm finally able to install the app without much trouble. Thanks – cavpollo Apr 05 '21 at 21:07
  • btw, if you have defined flavour. run `./gradlew task` to find out the correct install option – Yeung Mar 14 '23 at 04:24
2

For me it would get stuck at: Performing Streamed Install forever.

What fixed it was the old-age answer: unplugging and replugging my USB cable into my phone and then trying again.

Yuniac
  • 343
  • 3
  • 11
1

You can start by uninstalling the package if it exist on the device:

Check if the package name of your App exist

$ adb shell dumpsys package com.package.name
  • if it exist:
$ adb shell pm uninstall --user 0 com.package.name

if the uninstall failed then maybe the application is device admin or device owner.

  • if it does not exist:

Try changing the install flag of Android studio: Run > Edit configurations > Install Flags

pm install --user 0

Note: the command is pm install --user 0 without adb shell

Update:

Let's suppose that the App was never installed on the device.

  1. First install
adb install myapp.apk

The command will succeed and the application will be installed.

  1. Second install
adb install myapp.apk

The command will fail as you already installed a package com.package.name

For the second time you install, you should uninstall first:

adb uninstall com.package.name
adb install myapp.apk

or force to reinstall:

adb install -r myapp.apk
Community
  • 1
  • 1
St0rm
  • 391
  • 2
  • 9
  • The uninstall command is really handy, didn't know about it. Unfortunately the app still fails to be installed after being uninstalled or not being present. – cavpollo Aug 21 '20 at 09:43
  • Thanks for the explanation, but the install step keeps failing randomly even when the app has been properly uninstalled, even with a force install. – cavpollo Aug 22 '20 at 13:09
  • I've updated my question to be a bit more focused on the important issue. – cavpollo Aug 22 '20 at 13:38
0

Try disabled USB debugging mode and enabling it again on your phone. Sometimes it gets bugged and acts as if its disabled, when its set as enabled

Tal Mantelmakher
  • 994
  • 1
  • 7
  • 23
0

try update adb to latest version

can fix: adb install xxx.apk stuck at Performing Streamed Install`

More detail can refer: android - Error: ADB exited with exit code 1 Performing Streamed Install - Stack Overflow

crifan
  • 12,947
  • 1
  • 71
  • 56
  • I did try using different versions of the `adb`, as [that resulted to be an issue in the past](https://stackoverflow.com/q/61318644/1305745), but it not solve the issue. – cavpollo Dec 04 '20 at 10:18
  • @cavpollo please try another PC and reinstall adb dicrectly (not use android studio), check whether work or not – crifan Dec 07 '20 at 05:23