[Android] Upload package to device fails
I'm trying to build the default example but it fails uploading the package to my device (Android 5.0):
Exceptions thrown while deploying.
command: react-native run-android
OS: Linux 15.04 64-bits
Log:
: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: Unable to upload some APKs
* 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: 20.863 secs
Could not install the app on the device, see the error above.```
So I managed to enable the remote dev server via wi-fi and got everything to work generating a debug apk.
It works for now.
Steps (for those who are interested):
cdinto /android and run./gradlew assemble**- upload*
app-debug.apkfromandroid/app/build/outputs/apk/to phone and install it (you might need to enable unknown sources) - Run app, ignore the red screen, errors on the left and
Unable to load JS bundle - Shake device to inflate the dev menu:
- check (true)
Auto reload on JS change - open
Debug server host for deviceand type your computer IP address
- check (true)
- return to your host computer and run on terminal
react-native start - restart the app/reload js on your phone and it's ready to go
* I use Pushbullet and it works like charm for this kind of tasks ** Optional: Enable the daemon for faster builds
Do you have device debugging enabled on your phone? Do you see your device in the output of adb devices command?
@kmagiera correct, I tried under adb tcpip (wifi) -> adb connect and usb and got the same error.
Glad you got this to work. "Unable to upload some APKs" is a generic Gradle error, do you have spaces in your project name by chance? Google gives me: https://code.google.com/p/android/issues/detail?id=180674
I'm experiencing the same issue.
Huawei P8 - Android 5.0 OS: OSX 10.10.4
Enabled usb debugging and allowing all sources. My project name does not contain any special characters or spaces.
Edit: I can confirm that the remote dev server workaround by @peduxe works though.
@mkonicek nope the project name is just: rn
Looks like there are two separate issues here:
- "Unable to upload some APKs" from Gradle. This is Gradle-specific and I'd Google to find out why this is happening.
- Getting the app to load JS from the host machine. The steps you described are very similar to the docs, looks like we should add the step to restart the app.
Do you need the step react-native start? I would expect react-native run-android to start the packager in a new window before failing in Gradle.
@mkonicek It doesn't get to the point of uploading the app to my device, fails on the first step - also no new window (terminal tab?) is open during react-native run-android.
The react-native server needs to be executing before running react-native run-android?
@peduxe Try entering android dir inside your project and running ./gradlew :app:installDebug from there.
@kmagiera same errors.
Try running it with --debug
@kmagiera nothing, but now outputs much more verbose logs
Do you mind posting your logs here?
@kmagiera It's a bit long
Met the same issue.
Device: MEIZU m2 note - Android 5.1 OS: OSX 10.10.5
BTW, the workaround provided by @peduxe is also worked for me.
The same application can run on my Nexus 7 (Android 5.1) without issues.
@conechan you can connect with adb reverse, no need to set the host machine.
Make sure your device is connected via USB and run adb reverse tcp:8081 tcp:8081, then run react-native start.
I also met this problem.
:app:installDebug Installing APK 'app-debug.apk' on 'Redmi Note 2 - 5.0.2' 01:19:19 E/1160857647: Error while uploading app-debug.apk : Unknown failure Unable to install /Users/everplus/Documents/Project/CtripFxReactNative/android/app/build/outputs/apk/app-debug.apk com.android.ddmlib.InstallException: Unable to upload some APKs at com.android.ddmlib.Device.installPackages(Device.java:920) 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)
I try to use android studio with project, and that's ok.
@everplus yep it does work with AS, I believe it's the adb task to deploy the apk being used by react-native does not work for every device, I tested with a S5 and it worked.
I have the same problem, make sure you have allocate enough SD storage for your AVD. That's works for me!
@lazybios But i'm deploying to my own device, not the emulator :)