Failed to establish session
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
@facebook-github-bot duplicate #2720
@Kureev tells me this issue is a duplicate of #2720. Let's discuss there, closing this one.
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
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...
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
Seems to not work on Xiaomi Redmi Note 3 too. Can you please show explained way of solving this issue ?
you can disable MIUI on developer options after run react-native run-android
Works ! for those who suffer from this:
- 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.
- Go back to Settings, Additional settings, Developer options and enable USB Debugging.
- Connect your phone to your PC/Mac and on the phone authorize your computer
- go back to Developer options, scroll down to find Turn on MIUI optimization and disable it. Your phone will be rebooted
- Try it now :)
This problem confused me for a long time, thank you very much
@lironess Thank you! It works!
@lironess it work Thank you so much
Many thanks for you!
@lironess Thank you so so much,it works
@lironess Thanks, you saved my day 👍
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
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/
把小米开发者选项中最后一行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 谢谢,我关了的,不行。我报的错和题主不一样,我的是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 我的跟你的一样,改成1.2.3就可以了。。。。1.3.1的也一样不行,用的是MIUI手机,用模拟器的话都不用修改什么就运行起来了
What's the word on this issue?
works for me. thX!