New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to establish session #6499

Closed
guanMac opened this Issue Mar 17, 2016 · 42 comments

Comments

Projects
None yet
@guanMac

guanMac commented Mar 17, 2016

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

@Kureev

This comment has been minimized.

Contributor

Kureev commented Mar 17, 2016

@facebook-github-bot

This comment has been minimized.

facebook-github-bot commented Mar 17, 2016

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

@jiyinyiyong

This comment has been minimized.

jiyinyiyong commented May 18, 2016

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

@bintansiregar

This comment has been minimized.

bintansiregar commented Jun 12, 2016

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

@lironess

This comment has been minimized.

lironess commented Jun 27, 2016

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

@Shinichi52

This comment has been minimized.

Shinichi52 commented Jun 29, 2016

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

@lironess

This comment has been minimized.

lironess commented Jun 29, 2016

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 :)
@idisfkj

This comment has been minimized.

idisfkj commented Jul 1, 2016

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

@danilvalov

This comment has been minimized.

danilvalov commented Jul 1, 2016

@lironess Thank you! It works!

@huangMingHua

This comment has been minimized.

huangMingHua commented Jul 12, 2016

@lironess it work Thank you so much

@SanShiSir

This comment has been minimized.

SanShiSir commented Aug 13, 2016

Many thanks for you!

@VentionYC

This comment has been minimized.

VentionYC commented Sep 7, 2016

@lironess Thank you so so much,it works

@qutek

This comment has been minimized.

qutek commented Sep 24, 2016

@lironess Thanks, you saved my day 👍

@AndyFightting

This comment has been minimized.

AndyFightting commented Nov 23, 2016

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

This comment has been minimized.

AndyFightting commented Nov 23, 2016

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/

@VentionYC

This comment has been minimized.

VentionYC commented Nov 23, 2016

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

发自我的 iPhone

在 2016年11月23日,15:45,阿贵 notifications@github.com 写道:

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.

@AndyFightting

This comment has been minimized.

AndyFightting commented Nov 23, 2016

@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??我不知道为什么...先跑起来再说了....

@DDstar

This comment has been minimized.

DDstar commented Dec 5, 2016

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

@abhisheksoni27

This comment has been minimized.

abhisheksoni27 commented Dec 18, 2016

What's the word on this issue?

@miukki

This comment has been minimized.

miukki commented Jan 3, 2017

works for me. thX!

@t2krew

This comment has been minimized.

t2krew commented Feb 23, 2017

@lironess Thank you !

@NayeemUrRehman

This comment has been minimized.

NayeemUrRehman commented Feb 26, 2017

@lironess Thank you!!... after trying all permutations and combination ... finally this helped me to sort the problem ... also advise for every1 here dont use MI phone for debugging it will not allow you to taste the actual flavour of android ... thank you all !!!!

@codeheadshopon

This comment has been minimized.

codeheadshopon commented Mar 5, 2017

@lironess Answer Worked for Xiomi. I think that is the solution for Xiomi handsets. Thanks mate :)

@RomilChristian

This comment has been minimized.

RomilChristian commented Mar 6, 2017

thank you very much man.

@FlogFly

This comment has been minimized.

FlogFly commented Mar 7, 2017

thank you very much ,close the optimization mui is works for me

@d4rkm3z

This comment has been minimized.

d4rkm3z commented Mar 15, 2017

Thanks, work on Xiaomi Redmi 4 Pro/Prime

@ravkr

This comment has been minimized.

ravkr commented Mar 17, 2017

Thanks SOOO MUCH!
Xiaomi Redmi 3S 😃

@liuliangsir

This comment has been minimized.

liuliangsir commented Mar 22, 2017

Thanks,
Solution: disabled Xiaomi 5 connection
Namely, pull the usb cable
Because, i charge phone by using usb cable

@pickfire

This comment has been minimized.

pickfire commented Apr 7, 2017

Thanks a lot.

On redmi note 3s, once I disabled 使用MIUI优化 from settings and now it works.

@juicechu

This comment has been minimized.

juicechu commented Apr 12, 2017

@AndyFightting thx, it work. gradle version change to 1.2.3

@SanalKumarK

This comment has been minimized.

SanalKumarK commented Apr 25, 2017

@lironess That worked for my Redmi note also... Thanks...

@praveen180490

This comment has been minimized.

praveen180490 commented Apr 25, 2017

Thanks.. That also worked for my Redmi 3S Prime..

@fajrinimamarif

This comment has been minimized.

fajrinimamarif commented Jun 16, 2017

thanks

@MrChinmaya

This comment has been minimized.

MrChinmaya commented Nov 4, 2017

@lironess Thanks Buddy. Works for Redmi Note3.

@amit1999999

This comment has been minimized.

amit1999999 commented Dec 25, 2017

i am using Xiomi readmi 4 it is not woking...i am stuck

@amit1999999

This comment has been minimized.

amit1999999 commented Dec 25, 2017

any body help,,,,with Xiomi read mi 4 i am working its no working

@Janaksan

This comment has been minimized.

Janaksan commented Jan 17, 2018

@lironess Oh man Thank you so much. It's Working. You save my time.

@themakerman

This comment has been minimized.

themakerman commented Jan 18, 2018

Haha works like a charm...REDMI NOTE 4

@yinglovezhuzhu

This comment has been minimized.

yinglovezhuzhu commented Feb 1, 2018

If your android device os version is above 5.0, you need to run cmd 'adb reverse tcp:8081 tcp:8081'

@wajih123

This comment has been minimized.

wajih123 commented Apr 10, 2018

my problem in with the emulator its the one thats give me that error

@afresh

This comment has been minimized.

afresh commented Apr 14, 2018

com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.lovecode signatures do not match the previously installed version; ignoring!

因为手机中已经存在的相同包名的APK,将其删除就行了。

@gupta-ji6

This comment has been minimized.

gupta-ji6 commented May 15, 2018

@lironess Thanks for the solution! Worked for me.

@facebook facebook locked as resolved and limited conversation to collaborators May 24, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.