androidandroid-studioadbandroid-install-apk

Android Studio stuck at installing APK, the adb sometimes fails to install the APK, and somehow Android Studio interferes with adb's install command


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?


Solution

  • 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