Can't run/debug app on phone while connected through USB while using Android Studio (it disconnects when installing)
Asked Answered
M

1

0

I got an app that I'm perfectly able to run/debug while connected through USB from Android Studio on my Nexus 5 (Android 6) and LG Stylus 2 Plus (Android 8) phones, but it seems to fail when testing it on my Huawei P30 (Android 9).

I'm able to see all 3 devices as available from Android Studios' "Device File Explorer" tab, and browse the files in it, so I know that it is able to connect just fine.

Still, whenever I try to debug or run the app on my Huawei, the app is built, and as soon as it is going to start the install process, the phone disconnects and is immediately reconnected to the PC, resulting in a failed installation attempt.

All I can see from Android Studio is the following message:

Installation did not succeed.
The application could not be installed.
Installation failed due to: 'device 'ABCDEFGHIJKLM' not found'

I did have trouble getting the right drivers for the Huawei P30, but I believe that if I'm able to see the phone's files now, this should not be a driver issue anymore.

I've tried every phone configuration in the phone's developer options that I could find to no effect.

Miguel answered 20/4, 2020 at 8:59 Comment(0)
M
1

TL;DR:

These two android tools' versions were outdated:

  • Android SDK Build-Tools

  • Android SDK Platform-Tools

Update all android tools to the latest version, and make sure no old ones linger around, and you should be good to go. =)


After I tried to upload the APK directly into my phone from Android Studios' "Device File Explorer" tab and it failed with the same behaviour, I knew something was wrong with the adb-server. So I proceeded to run the adb directly from the console with the following commands:

$ adb start-server
$ adb push abcdefg.apk 

The server started just fine, and resulted in the same behavior, but this showed me a new error/warning message that I was never shown in Android Studio:

adb server version (30) doesn't match this client (41); killing...

This was enough for me to find questions and blogpost like this one: How to resolve - “adb server version (32) doesn't match this client (36); killing…”

I guess this phone is very new compared to the old Android tools I have installed, so basically, all I had to do was to update these 2 tools (to the latest version) from the Android Studios's Android SDK configuration menu:

  • Android SDK Build-Tools

  • Android SDK Platform-Tools

Android Studio's Android SDK configuration menu

Now, it is very important that you uninstall any old version of the tools that you may have lying around so that there is no chance that those get used (because it did happen to me during the process). You can check it by clicking the "Show package details" checkbox, and only check the latest version:

"Show package details" checkbox

After this, kill adb from the Task Manager (if it was running), and restart Android Studio. This should make sure you are not using any old version.

Miguel answered 20/4, 2020 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.