I am using Android Studio 2.2 Preview. I am facing the issue
Failure: Install failed invalid apk
Error: While installing apk,
I have made changes in build.gradle but could not retrack it, please suggest me solution???
I am using Android Studio 2.2 Preview. I am facing the issue
Failure: Install failed invalid apk
Error: While installing apk,
I have made changes in build.gradle but could not retrack it, please suggest me solution???
Android studio mac/windows/linux:
Steps in together (mac): Android Studio > Preferences > Build, Execution, Deployment > Instant Run > Uncheck : Enable Instant Run
Steps in together (windows & linux): File > Settings > Build, Execution, Deployment > Instant Run > Uncheck : Enable Instant Run
Steps in Detail :
Steps 1: Studio > Preferences (for windows & linux got to File > settings > Build, Execution, Deployment and then same as mac)
Steps 2: Preferences > Build, Execution, Deployment
Steps 3: Build, Execution, Deployment > Instant Run
Steps 4: Instant Run > Uncheck : Enable Instant Run
In Android Studio 2.3
Disable Instant Run
Settings>Build, Execution, Deployment>Instant Run
Source: comment by @Shubham A.
Edit: To Disable Instant run
In Windows:
Control + Shift + A. instant run and open instant run under settings.Enable instant run...In Mac: I don't have a mac, so try like
Command + Shift + A. instant run and open instant run under settings.Enable instant run... Disable Instant Run. Steps in Android Studio
Goto
1. File -> setting(or CLRT+ALT+S)
2. Build, Execution, Deployment -> Instant Run
3. Disable Instant Run
step by step (windows)
step 1 : Go to file -> settings
step 2 : Build, Execution, Deployment -> Instant Run
step 3 : disable the instant values
step 4 : finally disable the Instant Run
For Xiaomi mobile
1.Setting=>About phone=>tap 7 times on MIUI version
2.Setting=>Developer options=> Developer options (ON)
=> USB Debugging (ON)
=> Install via USB(ON)
Install via USB
if
enable to ON then
Disable WiFi and switch install via USB on while you are connected through mobile data and under your xiaomi account. It works!
In lollipop and above versions Android introduced multiple users, When you delete an app it still exists in device. Please make sure your app is deleted from all users and then reinstall it.
You can check by going to Settings->Apps->All and check your app in the list, On selecting your app tap on more button in actionbar and select uninstall for all users.
Different solutions for the same problem:
1. uncheck the Instant Run
Settings > Build, Execution, Deployment > Instant Run.
2. Restart Android Studio
Click on File> invalidate Caches/Restart, then click on Invalidate and Restart button from the pop up window.
3. Check Device's memory
Sometimes your device don't have enough space to install new applications, in that case android studio through this error.
4. Check manifest for Activities Declaration
Make sure that your manifest.java have declared all of the used activities properly.
Hope it would help :)
Below solution worked for my Xiaomi mobile phone:
Go to Settings -> Additional settings -> Developer options and check Install via USB, if toast The device is temporarily restricted shown, please turn your WI-FI off, turn on mobile data. Then try it again.
If A.S. Instance Run is still not work when you finished all steps above, perhaps you turned on MIUI optimization, please follow below step and try again:
Settings -> Additional settings -> Developer options and uncheck Turn on MIUI optimization
Android Install on Device Failure [INSTALL_CANCELED_BY_USER] **Redmi Note 3
Go to Settings -> Permissions -> Install via USB: Uncheck your App if it's listed.
Go to Settings -> Additional Settings -> Privacy: Check the Unknown Sources option.
Go to Settings -> Additional Settings -> Developer options: Check the Install via USB option.
Go to Settings -> Additional Settings -> Developer options:Enable view attribute inspection
Finally Go to Settings -> Additional Settings -> Developer options:Turn off MIUI optimization.
NOTE - Signin in to MI account is required to enable Install via USB option.
I also had the same problem, I tried the solution to disable the instant run, but you can not use the instant run, which for me is harmful, because it is an extremely useful tool.
I found another solution, which is to delete the "build" folder and re-run the project, and the error disappears, the app is executed and I can use the instant run.

This error comes with Android Studio lower than 2.4 when you try to enable Java 8 features in gradle settings following the instruction. Error can be reproduced in a new project with those gradle settings.
A higher version is needed, or a preview one.
Solution for my specific case:
Maybe it has happened because you have installed your apk first by the Google Play (my apk was running OK until I found an error) and then trying to reinstall it from your Android Studio (in order to figure it out), I have a solution:
Go to your phone/tablet. Settings -> Backup & Reset -> Disable Automatic Restore
I hope it works :)