react-native :app:installDebug FAILED

AndroidReact Native

Android Problem Overview


Install APK debug to my device failed.

jianglinghuadeMacBook-Pro:hello jianglinghua$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug...
WARNING [Project: :app] Current NDK support is deprecated.  Alternative will be provided in the future.
:app:preBuild UP-TO-DATE
......
:app:assembleDebug UP-TO-DATE
:app:installDebug
Installing APK 'app-debug.apk' on 'MI NOTE LTE - 6.0.1'
Unable to install /Users/jianglinghua/Desktop/hello/android/app/build/outputs/apk/app-debug.apk
com.android.ddmlib.InstallException: Failed to establish session
	at com.android.ddmlib.Device.installPackages(Device.java:894)
    ........
	at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
:app:installDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 13.945 secs

Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html

I look at my devices

jianglinghuadeMacBook-Pro:hello jianglinghua$ adb devices
List of devices attached
98333978	device

Android Solutions


Solution 1 - Android

Since you are using Mi phone which has MIUI

try this

go to Developer options, scroll down to find 'Turn on MIUI optimization' & disable it. Your Phone will be rebooted

check now


If you are using any other android phone, which has a custom skin/UI on top of android OS, then try disabling the optimization provided by that UI and check.
(usually you can find that in 'Developer options')

Solution 2 - Android

In my case, I have set up a new app but I was getting errors, tried many possible ways and answers from github and stackoverflow. nothing worked

error enter image description here The solution for me was .. check if you already have an app with the same name is installed in android..

> Delete old apps and run react-native run-android

Worked for me.

Solution 3 - Android

On my android device, the problem was about the previous build versions of the application that I had installed on my phone before. the following steps solved my problem:

  1. removing any previous build of the application, including debugging version and signed apk version

  2. On windows: On the root directory of your project, run :

    cd android

    .\gradlew clean

    cd ..

    npm cache clean --force

On MacOS: On the root directory of your project, run :

 <code>cd android</code>
 <code>./gradlew clean</code>
 <code>cd .. </code>

3. reboot your android device 4. run react-native run-android

Solution 4 - Android

I had this issue. Mine worked on the emulator well but it didn't work on the device and the error was

> app:installDebug FAILED.

If you have a different app with the same name (or package name) on the device: Rename the app or delete it from your device.

Solution 5 - Android

This works for me

  1. Uninstall the app from your phone
  2. cd android
  3. gradlew clean
  4. cd ..
  5. react-native run-android

Solution 6 - Android

I got the same problem and did some research. This problem happens a lot on Chinese android phones.

It was solved by change the gradle version to 1.2.3 in file android/build.gradle line 8

classpath 'com.android.tools.build:gradle:1.2.3'

Solution 7 - Android

Step 1: Close Android Emulator.

Step 2: Open Android Virtual Device Manager and wipe data by the following image: enter image description here

Step 3: Open your terminal and type

cd android
.\gradlew clean
cd ..
npm cache clean --force

Step 4: In terminal, run:

yarn run android

Note: If you are using yarn, just run:

yarn cache clean

Solution 8 - Android

  1. Go to android/build.gradle, change

classpath 'com.android.tools.build:gradle:2.2.3' to

classpath 'com.android.tools.build:gradle:1.2.3'

  1. Then, go to android/gradle/wrapper/gradle-wrapper.properties, change distributionURL to https://services.gradle.org/distributions/gradle-2.2-all.zip

  2. Run again.

Solution 9 - Android

If none of the above solutions works then try the following steps to cold boot the emulator

open AVD manager -> Edit device -> Show Advanced Settings -> Boot option -> select Cold Boot instead of Quick boot.

Solution 10 - Android

In my case (with React Native), my Android phone was unrecognized by my PC where I was running the server, which can be seen by the message:

* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No online devices found.

If that is the case, as highlighted in https://stackoverflow.com/questions/23081263/adb-android-device-unauthorized, make sure that in Developer Options on your phone USB Debugging is set to true, and enter the following commands in terminal or cmd to restart the Android server.

adb kill-server
adb start-server

And adb devices should list your phone as device instead of unauthorized

Solution 11 - Android

I had this problem and I removed the apk file from my android device/emulator and then run react-native run-android and run successfuly .

Solution 12 - Android

I also got troubles with app using gradle 2.14, though with gradle 4 it's ok. By using --deviceID flag app instals without any issue.

react-native run-android --deviceId=mydeviceid

Solution 13 - Android

In my case, I had the app downloaded from PlayStore and I was trying to debug the APK with the same name. I just uninstalled the app and debugged successfully.

Solution 14 - Android

open avd manager click on the arrow next to the pencil icon and wipe data works for me...

Solution 15 - Android

In my case, I manually delete the app-debug.apk file and run it again.

Solution 16 - Android

  1. Delete the app from the device.
  2. Edit the file (YourAppName -> android -> app -> build.gradle) enter the line below on the defaultConfig field

> multiDexEnabled true

defaultConfig {
    multiDexEnabled true //this is the line you need to enter
    applicationId "xxxxxx"
    minSdkVersion xxxxx
    targetSdkVersion xxxxx
    versionCode xx
    versionName "xx"
}

3) rebuild the app

Solution 17 - Android

Android device running out of memory, may be that is the reason.

Solution 18 - Android

cd android and run ./gradlew clean

After that create a new virtual device that should work

Solution 19 - Android

On MIUI , inside developer option by default "Install via USB" is disabled.Enable it and than it allows installing app via usb.

Solution 20 - Android

In my case, I did not have enough space on my device to install the app, so I cleared up some space and tried again

Solution 21 - Android

Just go to the Developer option in your phone and disable and again enable usb debugging. It will work.

Solution 22 - Android

For me, restarting my phone did the trick.

Solution 23 - Android

Previously, I had installed npm and then installed yarn, and that is when I started to have problems compiling, even when creating new projects with react-native init . Uninstalling yarn, I was able to create and compile.

Solution 24 - Android

I got the same error but the issue was I did on the USB Debugging after unable this is working for me.

enter image description here

Solution 25 - Android

As you add more modules to Android, there is an incredible demand placed on the Android build system, and the default memory settings will not work. To avoid OutOfMemory errors during Android builds, you should uncomment the alternate Gradle memory setting present in /android/gradle.properties:

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Solution 26 - Android

In my case, It is problem of permissions or we can say that setting problem present inside developer options. I am using MI Note 10.To avoid this issue,permit some setting such as common one developer option and USB debugging as well as Install via USB,USB debugging(Security settings), Verify apps over USB.

Solution 27 - Android

I solved this issue by deleting the current device and just creating a new one.

Solution 28 - Android

I had the same issue with wrong AVD settings. Probably, "Target Android 6.0" was wrong choice.

Next settings were changed to fix ":app:installDebug FAILED" issue: System Image: Marshmallow , API 23, ABI x86, Target Google API.

see the detail information about this here: RN Android Setup

Solution 29 - Android

Just lock and unlock the android solved my issue then

adb reverse tcp:8081 tcp:8081

Solution 30 - Android

my solution is delete the android/app/build folder

Solution 31 - Android

For me I solved it by uninstalling the already existing app from my phone first (which I was working on the day before the day I got this issue) then building again, it happened to me a few times I think that's how I solved it always.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Question江玲华View Question on Stackoverflow
Solution 1 - AndroidanmolakhileshView Answer on Stackoverflow
Solution 2 - AndroidJahanzeb NawazView Answer on Stackoverflow
Solution 3 - AndroidMahdieh ShavandiView Answer on Stackoverflow
Solution 4 - AndroidMohsen BiglariView Answer on Stackoverflow
Solution 5 - AndroidHammad HassanView Answer on Stackoverflow
Solution 6 - AndroidDubboView Answer on Stackoverflow
Solution 7 - AndroidHai DinhView Answer on Stackoverflow
Solution 8 - AndroidIkhwanul MusliminView Answer on Stackoverflow
Solution 9 - AndroidCodeZombieView Answer on Stackoverflow
Solution 10 - AndroidLarryView Answer on Stackoverflow
Solution 11 - AndroidHamed DamirchiView Answer on Stackoverflow
Solution 12 - AndroidNerius JokView Answer on Stackoverflow
Solution 13 - AndroidCPJView Answer on Stackoverflow
Solution 14 - AndroidUmair RaeesView Answer on Stackoverflow
Solution 15 - AndroidAbraham Anak AgungView Answer on Stackoverflow
Solution 16 - AndroidMoh .SView Answer on Stackoverflow
Solution 17 - AndroidVigneshwaran ChandrasekaranView Answer on Stackoverflow
Solution 18 - Androidshankar upadhyayView Answer on Stackoverflow
Solution 19 - AndroidSharthakView Answer on Stackoverflow
Solution 20 - Androidsumukha hegdeView Answer on Stackoverflow
Solution 21 - AndroidAmit Kumar TrivediView Answer on Stackoverflow
Solution 22 - AndroidSunwoo YangView Answer on Stackoverflow
Solution 23 - AndroidJxDarkAngelView Answer on Stackoverflow
Solution 24 - AndroidParveen ChauhanView Answer on Stackoverflow
Solution 25 - AndroidJustin.MathewView Answer on Stackoverflow
Solution 26 - AndroidRutuja KherdeView Answer on Stackoverflow
Solution 27 - AndroidHadrien JaubertView Answer on Stackoverflow
Solution 28 - AndroidmikowiecView Answer on Stackoverflow
Solution 29 - AndroidZeeshan AnsariView Answer on Stackoverflow
Solution 30 - AndroidtylimView Answer on Stackoverflow
Solution 31 - AndroidYuniacView Answer on Stackoverflow