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

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)

Solution 1:

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:

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

Solution 3:

adb is known to be flaky. Try:

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