64
votes

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)
16
Note that react-native run-android also starts the packager, no need to start it manually.Martin Konicek
I resolved this issue, by simply creating a new android virtual device. Not exactly sure what was causing it.Magnuss

16 Answers

246
votes

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 :)
17
votes

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

11
votes

adb is known to be flaky. Try:

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

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

6
votes

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

4
votes

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

3
votes

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.

2
votes

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

1
votes

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

0
votes

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.

0
votes

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.

0
votes

01 - Uninstall the app installed in device

03- then run

  • adb kill-server

02 -Then run again

  • react-native run-android
0
votes

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 :)

0
votes
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.
0
votes

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

0
votes

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