[Original] Xiaomi mobile phone cannot be debugged on real machine

System environment:
Xiaomi Mi 2S
MIUI version: 8.0.1.0 (LXACNDG)
Android version: 5.0.2 LRX22G
Android Studio version: 2.3.3

There are many reasons for not being able to use Xiaomi mobile phone for real device debugging, here is only the situation I encountered And the solution

phenomenon
has been able to use the mobile phone for real machine debugging. However, when developing a new application today, real machine debugging is not possible. After clicking the "Run" button in Android Studio, the following prompt appears:
quote
Installation failed with message Failed to establish session.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.

WARNING: Uninstalling will remove the application data!

Do you want to uninstall the existing application?

This has never happened before in development. So I searched the Internet for a long time to no avail. Consequences After carefully thinking about the difference between this development and the previous development, it was possible to debug on a real machine before, but not this time. Later, I finally reacted. During this development, I upgraded the Gradle version and the Android Plugin Version to the latest version. Could it be caused by this problem. So these two versions were modified to the old version that was used before: the

solution is to
restore the latest version:
Gradle version: 3.3
Android Plugin Version: 2.3.3
to:
Gradle version: 2.14.1
Android Plugin Version: 2.2.0

and then again When running, it can be debugged normally on the real machine.

PS:
For the correspondence between the Gradle version and the Android Plugin Version, see the official website:
https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326152535&siteId=291194637