com.android.ddmlib.InstallException: Failed to establish session react-native

AndroidReact Native

Android Problem Overview


I am trying to run react-native android app in my nexus5 emulator

adb devices
List of devices attached
emulator-5554   device

started packager react-native start

running app - react-native run-android

Installing APK 'app-debug.apk' on 'reactnative(AVD) - 6.0' Unable to install examples/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 com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:113)
        at com.android.builder.testing.ConnectedDevice$installPackages$0.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
        at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.groovy:119)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)

Android Solutions


Solution 1 - Android

For Mi devices

for those who suffer from this, try what lironess mentions in a Github Comment

> 1. enable developer mode - In your phone, go to Settings, About phone and click on MIUI version 7 times. You’ll see a pop up which > says you are a developer now. > 2. Go back to Settings, Additional settings, Developer options and enable USB Debugging. > 3. Connect your phone to your PC/Mac and on the phone authorize your computer > 4. go back to Developer options, scroll down to find Turn on MIUI optimization and disable it. Your phone will be rebooted > 5. Try it now :)

Solution 2 - Android

Try : react-native run-android --deviceId YOUR_ID.

Solution 3 - Android

adb is known to be flaky. Try:

  • Restarting adb with $ adb kill-server
  • Restarting the emulator
  • Using Genymotion instead of stock Google emulator.

Solution 4 - Android

For your AVD emulator settings, try to make sure the "Use Host GPU" setting is checked, and relaunch the emulator and try again.

Solution 5 - Android

In my case, I have to run this command in
/sdklocation/platform-tools/

 adb kill-server

then run again and watch for install request on the phone.
hope this help some one

Solution 6 - Android

For those like me having this issue in the emulator, one more tip: try to free up the available storage space in the emulator. That worked for me.

So many test apps and previous developed apps installed XD

Solution 7 - Android

If your device or emulator have an application having same name with the application you are building. Just remove the old one. It will resolve the issue.

Solution 8 - Android

If you had already installed app on device go delete it. It's work for me

Solution 9 - Android

Simply go to developer options and enable Install via USB below Debugging options.

https://i.stack.imgur.com/caTXW.jpg" height="250" />

Solution 10 - Android

Even i had the same problem,but restarting the genymotion and running the "react-native run-android" again worked for me. Ensure genymotion is running before running the above command.

Solution 11 - Android

Probable Cause

> I faced this issue recently , I had first developed an app called > 'myApp' in CordovaJS where the app domain was com.myapp and had it > installed (this was months before I got into react ). Then when I > switched to react-native I did an app with a domain com.myapp and ran > into the same problem you are in.

So I figured out that there was conflicts when it came to domain and source .

Solution :

> Uninstall the app that has a similar domain as the one that you are > installing eg com.example , then reboot your phone .

It worked for me , I hope it works for you too.

Solution 12 - Android

01 - Uninstall the app installed in device

03- then run

  • adb kill-server

02 -Then run again

  • react-native run-android

Solution 13 - Android

This issue happens to occur in Xiomi devices. In developers option, you don't have to disable MIUI optimization(disabling this won't sync your accounts) instead, enable 'USB debugging' option along with 'Install via USB' and 'USB debugging(Security settings)'. This will solve the issue :)

Solution 14 - Android

Sometimes it may happened due to insufficient storage within emulator.Try something like below:
   1. Stop emulator
   2. Open AVD Manager -> Wipe Data
   3. Start emulator and run your project.

Solution 15 - Android

step :1 run(kill all adb)

 adb kill-server

step 2:list all connected devices(get your emulator id)

adb devices 

step 3:(replace ID to listed id from step2)

react-native run-android --deviceId ID

Note: make sure your previous app uninstalled in your emulator or physical device

Solution 16 - Android

In MI Devices. I solve this problem by goto Developer options -> turn on Install via USB. I hope it useful!

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
QuestioninvariantView Question on Stackoverflow
Solution 1 - Androidshrestha rohitView Answer on Stackoverflow
Solution 2 - AndroidBadis MerabetView Answer on Stackoverflow
Solution 3 - AndroidMartin KonicekView Answer on Stackoverflow
Solution 4 - AndroidEdward TanView Answer on Stackoverflow
Solution 5 - AndroidmaxView Answer on Stackoverflow
Solution 6 - AndroidCosmitarView Answer on Stackoverflow
Solution 7 - AndroidCodemakerView Answer on Stackoverflow
Solution 8 - AndroidKhalid AhmadaView Answer on Stackoverflow
Solution 9 - AndroidAkshat SinghalView Answer on Stackoverflow
Solution 10 - AndroidThanmai CView Answer on Stackoverflow
Solution 11 - AndroidDaggie Blanqx - Douglas MwangiView Answer on Stackoverflow
Solution 12 - AndroidRumesh MadushankaView Answer on Stackoverflow
Solution 13 - AndroidAishwarya MundadaView Answer on Stackoverflow
Solution 14 - AndroidSanakhatun ShaikhView Answer on Stackoverflow
Solution 15 - AndroidßãlãjîView Answer on Stackoverflow
Solution 16 - AndroidDung NguyenView Answer on Stackoverflow