facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.59k stars 24.37k forks source link

[Android] Upload package to device fails #2720

Closed ghost closed 8 years ago

ghost commented 9 years ago

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.```
jawadrehman commented 9 years ago

I have noticed, that even after downgrading gradle it only worked when I uninstalled the app first.

ghost commented 9 years ago

@jawadrehman It should be replacing the apk on your device whenever you change your project resources, perhaps some error prior to deployment?

jawadrehman commented 9 years ago

@peduxe just to confirm are there problems with using the nexus 6 emulator + android api level 23 ?

with the configuration highlighted when trying to update the existing app

and then when i tried doing it after removing

Skipping device 'nexus(AVD)' for 'app:debug': Could not find build of variant which supports density -1 and an ABI in

jawadrehman commented 9 years ago

@peduxe interestingly this worked without hickup on the 32 bit. maybe there should be a mention that 64 bit throws an error on the support page ?

ghost commented 9 years ago

@jawadrehman I'm not using an emulator - it's really slow (even genymotion), I'm deploying to my device connected via usb/wi-fi

venil7 commented 9 years ago

restarting adb helps me resolve this issue

kwaak commented 9 years ago

Platform: Win 7 x64

I had the same issue trying to deploy to my device "'Redmi Note 2 - 5.0.2". Downgrading Gradle to 1.2.3 also worked for me. I also tried Gradle 1.5.0 but that did not work either.

I think we could find out more by running the pm commands manually how Gradle does it:

>> pm install-create -S [APK bytes]

sess id: [sess id]

>> pm install-write -S [APK bytes] [sess id] 0_app-debug -[stream binary APK here]

??? no idea which response would come here

>> pm install-commit [sess id]

And see if anything does fail.

speedcell4 commented 9 years ago

@peduxe thank you, downgrading to 1.2.3 also works for my project.

gapgag55 commented 8 years ago

@peduxe I also works with downgrading to 1.2.3 Thank!!

sryuliwa commented 8 years ago

@peduxe thanks,this just works for me :)

ghost commented 8 years ago

@gapgag55 @repstd :+1:

cablegunmaster commented 8 years ago

@peduxe I had the same issue.

The makers should put this in the tutorial: "Run server first before running the reactive-native run-android command"

How I resolved my issue:

In projectfolder:

$ <projectfolder>cd android 
$ <projectfolder>vim build.gradle 

and lowered the gradle version to 1.2.3

after that 1 terminal open with: $ adb reverse tcp:8081 tcp:8081 //startup server. $ react-native start

//open new terminal Ctrl + Alt + T in ubuntu go to project folder $ react-native run-android

leavesgreen commented 8 years ago

@peduxe "I'm not using an emulator - it's really slow (even genymotion), I'm deploying to my device connected via usb/wi-fi" so how you connected the device by the wifi? would you give me a link for more details ? thanks

holyxiaoxin commented 8 years ago

I have installed AwesomeProject previously from: http://facebook.github.io/react-native/docs/getting-started.html#content

I just had to uninstall it and run react-native run-android to get it installed properly.

delta-9 commented 8 years ago

The step described by @cablegunmaster is working for me,

I downgraded graddle to 1.2.3 in build.gradle after that 1 terminal open with: $ adb reverse tcp:8081 tcp:8081 //startup server. $ react-native start

//open new terminal Ctrl + Alt + T in ubuntu go to project folder $ react-native run-android

satya164 commented 8 years ago

Hey, closing this issue since it's an issue with the gradle setup rather than React Native. Feel free to continue the discussion to find potential fixes/workarounds.

woaiso commented 8 years ago

@peduxe change 'com.android.tools.build:gradle:1.3.1' to 1. 2.3 works fine MeiZu Metal M1

ilessy commented 8 years ago

@peduxe Thanks a lot. '1.2.3' worked for my 'MX5-5.1'

zhuhuang521 commented 8 years ago

zxs:app_lockop zxs$ react-native run-android JS server already running. Building and installing the app on the device (cd android && ./gradlew installDebug)... Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.htm

i don't know is there any problem with my project.

fab1an commented 8 years ago

I downgraded to classpath 'com.android.tools.build:gradle:1.2.3 as well. Can anyone of the team explain why?

My Android Studio build works, all my 15 other gradle-based java projects work, only react-native doesn't…

miqmago commented 8 years ago

For me it's very weird: it works fine with android device 4.3 and it miserably fails with a tablet 5.0 UPDATE: https://code.google.com/p/android/issues/detail?id=180674

fab1an commented 8 years ago

Maybe react-native doesn't work with Lollipop?

miqmago commented 8 years ago

The link before says the problem is when there are unescaped characters in app name. I've seen the name of the app is app-debug.apk, maybe there is a problem with hyphens too... Is it possible to force a change on the app name in order to try with appDebug.apk?

GerryQuest commented 8 years ago

Changing the version of com.android.tools.build:gradle to 1.5.0 worked for me.

leeight commented 8 years ago

+1

slott commented 8 years ago

This is still a problem for me - just updated to the latest firmware on my Xiao Mi 4C and the problem still persists. This has pretty much rendered my phone useless as a developer device ;(

fab1an commented 8 years ago

You can still use Android Studio with ReactNative. It will work from there.

olojiang commented 8 years ago

Downgrade to 1.2.3. It doesn't work for me, Xiao Mi 3W, Android 6.0.1.

What went wrong: Execution failed for task ':app:installDebug'. > com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session

olojiang commented 8 years ago

Also tried gradle 1.5.0, on the same device, has no luck, it still doesn't work.

OpenGG commented 8 years ago

@Eissek You rock, downgrading to 1.2.3 did not help me, but upgrading to 1.5.0 did.

OpenGG commented 8 years ago

@olojiang "Failed to establish session", it is likely the building process failed to communicate with your device via adb. Did you try adb devices or adb install android/app/build/outputs/apk/app-debug.apk?

OpenGG commented 8 years ago

@slott See my comment above.

And also to everyone in trouble with this problem, if ':app:installDebug' task failed, it means gradle fails to install app-debug.apk on your device via adb, but the apk itself has been generated.

If changing gradle version does not help, you can always try adb install android/app/build/outputs/apk/app-debug.apk.

fab1an commented 8 years ago

I think it has to do with a permission problem on the device.

As far as I know the gradle plugin copies the apk on the device first and then installs it with "adb shell pm install", which doesn't work.

Could you try running adb shell ls -l /data adb shell ls -l /data/local adb shell ls -l /data/local/tmp

to check the permissions.

By the way, I'm using com.android.tools.build:gradle:2.1.0 and just install the app with Android Studio.

Aspsine commented 8 years ago

For react-native Examples:

Step 1: Change react-native/build.gradle version to 1.2.3

classpath 'com.android.tools.build:gradle:1.2.3'

Step 2: Change react-native/gradle/wrapper/gradle-wrapper.properties to gradle-2.2-all.zip

distributionUrl=https://services.gradle.org/distributions/gradle-2.2-all.zip

Step 3: Run

./gradlew :Examples:UIExplorer:android:app:installDebug

Have fun

terry-fei commented 8 years ago

@Aspsine Not fun :( Failed to establish session

john-hu commented 8 years ago

@OpenGG I got the same issue like @olojiang.

I can use adb devices and use adb install to install the app. But the screen doesn't show anything, just all blank.

BTW, I can use "react-native run-android" with my emulator which gives me correct result.

tiye commented 8 years ago

My device is Xiaomi 4 LTE, tried gradle 1.5.1 1.2.3 1.2.0, none of them is working. :(

Aspsine commented 8 years ago

@jiyinyiyong MIUI permissions manager blocked the popup window. Make sure allowing your awesomeproject app show popup windows permission.

terry-fei commented 8 years ago

@Aspsine No chance to change permission, react-native run-android crash before install apk on device My device is Xiaomi Note

terry-fei commented 8 years ago

but work fun on my Nexus 6

chuguixin commented 8 years ago

@jiyinyiyong click...安全中心 -> 授权管理 -> ROOT权限管理...open root permission.. It works on my MI 4 LTE 6.0.1

tiye commented 8 years ago

@chuguixin In my menu there are "自启动管理" "应用权限管理" "USB安装管理", but no entry related to "root". My MIUI is 7.3.2.0.

terry-fei commented 8 years ago

@jiyinyiyong May be need '开发版' not '稳定版'

tiye commented 8 years ago

@feit @chuguixin confirmed working after installing MIUI developer edition. Thanks!

g7tianyi commented 8 years ago

Interesting, I just upgrade my gradle to 2.12, and it works.

cablegunmaster commented 8 years ago

@g7tianyi just for the interest of trying it won't let me do 2.12 -> got error:

FAILURE: Build failed with an exception.

BUILD FAILED

1.2.3 is for me sofar the only one that works Huawei P8 Smartphone.

yaoshanliang commented 8 years ago

I tried gradle 1.2.3, not working.

Then tried adb install android/app/build/outputs/apk/app-debug.apk, success.

bbtfr commented 8 years ago

I'm using MI 4 LTE 6.0.1, enable root permission works for me, without changing gradle version. Thanks @chuguixin

heat commented 8 years ago

Same issue with sony d6633

OpenGG commented 8 years ago

@john-hu I have no idea why gradle's installing process isn't a plain old adb install, and why it has to be this complicated. Just an advice for everyone that you can add one adb install command in the building script, bypassing this issue.