Solve the problem that Xiaomi phones cannot run Android Studio programs

Original: http://blog.csdn.net/android_03/article/details/60322955?utm_source=itdadao&utm_medium=referral

----------------------------------------------------------------------------------------------------

Problem Description

After Android Studio is upgraded to version 2.3, the Xiaomi mobile phone MIUI8 cannot run the Android Studio program, and the following error is reported:

Installation failed with message Failed to establish session.
It is possible that this issue is resolved by uninstalling an existing version of apk if it is present, and then re-installing

Question in detail

Solution

Method 1: Set the option in Instant Run in Android Studio to unchecked

(1) According to the following path, find the option 
File - Settings - Build, Execution, Deployment - Instant Run in Instant Run 
(2) Select Enable Instant Run to hot swap code/resource changes on deploy (default enabled) box canceled.

write picture description here

(3) Click Apply to save the settings and it is OK. 
At this time, you can run the program on the Xiaomi phone

Method 2: Turn off MIUI optimization in the developer mode of the phone

Enter the developer mode of the phone, there is an option to enable MIUI optimization at the bottom , closing this option will prompt to restart the phone, choose to close and restart after restarting, run our program again, and it can run on the phone.

write picture description here

Guess you like

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