Gradle: Error while uploading app-local-debug.apk : Unknown failure ([CDS]close[0])
Asked Answered
E

6

5

I am trying to use gradlew cAT command to perform the connected android tests with my android phone. But i get the below Error log and it cannot install the app.

  • The App gets installed if adb command is used.

  • The above command works ok with OnePlusOne phones but not in Lenovo and Asus

The error log is below:

Unable to install /home/admin/MyApp/app/build/outputs/apk/app-local-debug.apk
com.android.ddmlib.InstallException: Failed to install all 
        at com.android.ddmlib.SplitApkInstaller.install(SplitApkInstaller.java:91)
        at com.android.ddmlib.Device.installPackages(Device.java:901)
        at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:119)
        at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:121)
        at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Enunciate answered 15/9, 2016 at 19:30 Comment(0)
A
35

This happens to be a very common problem with most Chinese manufactured phones. The issue lies within your gradle-plugin dependencies and there are two ways you can go about solving it.


Option 1: Downgrade your gradle version.

Step 1: go to sampleProject/android/build.gradle at line 8 and Modify classpath to com.android.tools.build:gradle:1.2.3 or 1.2.1.

Step 2: go to sampleProject/android/gradle/wrapper/gradle-wrapper.properties at line 5 and Modify distributionUrl to https://services.gradle.org/distributions/gradle-2.2-all.zip


Option 2: Install manually

Step 1: Locate the app-debug.apk at sampleProject/android/app/build/outputs/apk.

Step 2:Copy and Paste into any folder in your phone then click to install it.

Step 3: Shake your phone to expose settings, click on Dev Settings then Debug Server host & port for device and configure it with your ip address(192.168.xx.xx:8081).

Start your react-native server and viola you are up and running!!!

EDIT!!!!!!!!

Doing either option listed above became so tiring and frustrating and I found another solution.


Option 3: Add device Id

Step 1: Make sure your device is connected and then run adb devices. From the output, grab the device id H80xxxxxx.

Step 2: Run react-native run-android --deviceId H80xxxxxx

NB: Personally I now use option 3 any time the error pops up!!

Afroasian answered 2/6, 2017 at 8:4 Comment(1)
the first option worked for me, but you need to run this command too: cd android && gradlew clean && cd .. && react-native run-androidCorabella
Y
0

Check using adb devices if your phones are correctly seen

If yes, try using adb to install app on your phone, if it is installed and works fine than run the tests using ./gradlew connectedAndroidTest(on linux).

According to issue: https://github.com/facebook/react-native/issues/2720

It may be a problem with Gradle plugin version, so if you still face the problem downgrade your gradle-plugin dependencies.

Hope it will help

Yacano answered 15/9, 2016 at 20:56 Comment(0)
L
0

Issue is because you might have connected both Emulator & Real device. Remove one them you should be good to go.

Since i had the same issue after removing my real device it fixed the error.

Lateral answered 28/9, 2017 at 9:7 Comment(0)
K
0

I uninstalled the apk from my device.After doing that My issue was fixed.

Kufic answered 25/7, 2018 at 3:19 Comment(0)
S
0

I have the same problem. My solution: delete the app-local-debug.apk or app-debug.apk file manually and run it again

Serotine answered 24/9, 2020 at 8:36 Comment(0)
T
0

I found that I had set archivesBaseName under defaultConfig so I can keep track of production bundle versions, and this included a space character. Once I removed the space character it was happy.

i.e. under module-level build.gradle change

android {
    ... 
    defaultConfig {
        ... 
        archivesBaseName = "myappname v${myVersionCode}"
        ...

to

android {
    ... 
    defaultConfig {
        ... 
        archivesBaseName = "myappname-v${myVersionCode}"
        ...
Twelfthtide answered 23/4 at 11:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.