Reputation: 8900
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)
Upvotes: 65
Views: 71280
Reputation: 4306
This might be caused by insufficient storage space in your device or emulator. Just free up some space and try. AFAIK, free up 600 MB + the space required for your app after installation + size of your app bundle (APK or AAB as the bundle is copied to the device before installation). It means that ~600 MB of space must be free after installation, else, your installation will be canceled.
Upvotes: 1
Reputation: 309
In MI Devices. I solve this problem by goto Developer options -> turn on Install via USB. I hope it useful!
Upvotes: 0
Reputation: 10877
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
Upvotes: 0
Reputation: 21
Simply go to developer options and enable Install via USB below Debugging options.
Upvotes: 2
Reputation: 2339
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.
Upvotes: 0
Reputation: 2940
For Mi devices
for those who suffer from this, try what lironess mentions in a Github Comment
- 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.
- Go back to Settings, Additional settings, Developer options and enable USB Debugging.
- Connect your phone to your PC/Mac and on the phone authorize your computer
- go back to Developer options, scroll down to find Turn on MIUI optimization and disable it. Your phone will be rebooted
- Try it now :)
Upvotes: 247
Reputation: 1
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 :)
Upvotes: 0
Reputation: 1
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.
Upvotes: 3
Reputation: 379
01 - Uninstall the app installed in device
03- then run
02 -Then run again
Upvotes: 0
Reputation: 2549
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.
Upvotes: 0
Reputation: 1084
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
Upvotes: 5
Reputation: 761
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.
Upvotes: 0
Reputation: 6177
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
Upvotes: 6
Reputation: 360
If you had already installed app on device go delete it. It's work for me
Upvotes: 2
Reputation: 954
For your AVD emulator settings, try to make sure the "Use Host GPU" setting is checked, and relaunch the emulator and try again.
Upvotes: 7
Reputation: 40904
adb is known to be flaky. Try:
$ adb kill-server
Upvotes: 11