Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)
like image 869
Roshan Chhetri Avatar asked Sep 15 '16 19:09

Roshan Chhetri


1 Answers

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!!

like image 154
Ernest Avatar answered Oct 17 '22 01:10

Ernest