react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Failed to establish session

Open kdocs-ai opened this issue 10 years ago • 42 comments

When I used 'react-natvie run-androi', it showed that:

:app:installDebug Installing APK 'app-debug.apk' on 'MI 4W - 6.0.1'

Execution failed for task ':app:installDebug'.

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session

my android phone is XIAOMI 4 , 6.0.1

kdocs-ai avatar Mar 17 '16 09:03 kdocs-ai

@facebook-github-bot duplicate #2720

Kureev avatar Mar 17 '16 09:03 Kureev

@Kureev tells me this issue is a duplicate of #2720. Let's discuss there, closing this one.

facebook-github-bot avatar Mar 17 '16 09:03 facebook-github-bot

Same error here but during ./gradlew installRelease. Also in XiaoMi 4, 6.0.1 . Some logs:

17:26:16.747 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':app:installDebug'.
17:26:20.299 [LIFECYCLE] [org.gradle.api.Task] Installing APK 'app-debug.apk' on 'MI 4LTE - 6.0.1'
17:26:21.840 [ERROR] [org.gradle.api.Task] Unable to install /Users/chen/repo/gist/Demo/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)
17:26:21.845 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 14.385 secs, idle: 0.049 secs
17:26:21.853 [ERROR] [org.gradle.BuildExceptionReporter]
17:26:21.855 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
17:26:21.855 [ERROR] [org.gradle.BuildExceptionReporter]
17:26:21.855 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
17:26:21.856 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:installDebug'.
17:26:21.856 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to establish session
17:26:21.857 [ERROR] [org.gradle.BuildExceptionReporter]
17:26:21.857 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
17:26:21.857 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:installDebug'.
17:26:21.858 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
17:26:21.858 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute

more log


update: someone told me to install MIUI developer edition and I found it worked. So the problem was that default OS does not gives enough permissions...

tiye avatar May 18 '16 09:05 tiye

Actually this problems comes from all of Xiaomi phones, MIUI block incoming action for installing adb from apk via usb. If you try install manual via "adb install nameofapk.apk" then of your Xiaomi's screen will pop permission that ask you to accept or deny installation from usb. That's the problem why apk won't automatically install when we type "react-native run-android", because that command use silent install via adb to Xiaomi Device. Silent install will not make pop up permission on Xiaomi's screen. So may the question is, how to remember permission access for install apk via adb usb, or maybe disable it.

Thanks

bintvn avatar Jun 12 '16 12:06 bintvn

Seems to not work on Xiaomi Redmi Note 3 too. Can you please show explained way of solving this issue ?

lironess avatar Jun 27 '16 05:06 lironess

you can disable MIUI on developer options after run react-native run-android

Shinichi52 avatar Jun 29 '16 09:06 Shinichi52

Works ! for those who suffer from this:

  1. 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.
  2. Go back to Settings, Additional settings, Developer options and enable USB Debugging.
  3. Connect your phone to your PC/Mac and on the phone authorize your computer
  4. go back to Developer options, scroll down to find Turn on MIUI optimization and disable it. Your phone will be rebooted
  5. Try it now :)

lironess avatar Jun 29 '16 10:06 lironess

This problem confused me for a long time, thank you very much

idisfkj avatar Jul 01 '16 03:07 idisfkj

@lironess Thank you! It works!

danilvalov avatar Jul 01 '16 18:07 danilvalov

@lironess it work Thank you so much

huangMingHua avatar Jul 12 '16 08:07 huangMingHua

Many thanks for you!

SanShiSir avatar Aug 13 '16 13:08 SanShiSir

@lironess Thank you so so much,it works

VentionYC avatar Sep 07 '16 07:09 VentionYC

@lironess Thanks, you saved my day 👍

qutek avatar Sep 24 '16 08:09 qutek

it does not work for me .... i can run on android emulator, but device can not. device is Xiao Mi MIUI8.0, and i try the 5 step upon.........it does not work....... //////////////////////////////////////////////////////////////////////////////////// :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: 9.064 secs 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.html

AndyFightting avatar Nov 23 '16 07:11 AndyFightting

i solved my problem. i change android/build.gradle file line 8, classpath 'com.android.tools.build:gradle:1.3.1' to classpath 'com.android.tools.build:gradle:1.2.3'. it works...

link :http://csbun.github.io/blog/2015/12/starting-react-native-with-android/

AndyFightting avatar Nov 23 '16 08:11 AndyFightting

把小米开发者选项中最后一行MIUI优化关掉就行

发自我的 iPhone

在 2016年11月23日,15:45,阿贵 [email protected] 写道:

it does not work for me .... i can run on android emulator, but device can not. device is Xiao Mi MIUI8.0, and i try the 5 step upon.........it does not work....... //////////////////////////////////////////////////////////////////////////////////// :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: 9.064 secs 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.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

VentionYC avatar Nov 23 '16 08:11 VentionYC

@VentionYC 谢谢,我关了的,不行。我报的错和题主不一样,我的是com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unable to upload some APKs。我是把gradle:1.3.1 改成 gradle:1.2.3 就可以了。再改回去还是不行...难道只能用gradle:1.2.3??我不知道为什么...先跑起来再说了....

AndyFightting avatar Nov 23 '16 10:11 AndyFightting

@AndyFightting 我的跟你的一样,改成1.2.3就可以了。。。。1.3.1的也一样不行,用的是MIUI手机,用模拟器的话都不用修改什么就运行起来了

DDstar avatar Dec 05 '16 03:12 DDstar

What's the word on this issue?

abhisheksoni27 avatar Dec 18 '16 07:12 abhisheksoni27

works for me. thX!

miukki avatar Jan 03 '17 10:01 miukki