Skip to content
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

[问题排查] Freeline "try to connect device/ connect_device_task failed." #152

Open
lomanyong opened this issue Sep 21, 2016 · 44 comments

Comments

@lomanyong
Copy link
Member

lomanyong commented Sep 21, 2016

排查方法如下(建议配合使用python freeline.py -d):

  1. 确定FreelineCore.init(this);加入到Application类中,且在onCreate()下的第一行,不要根据是否在主进程做特殊处理,否则可能导致FreelineService无法正常启动;[Freeline 0.7.0+开始,默认开启了Application替换,这条可以不用检查]
  2. 确定FreelineService以及freeline相关组件是否正常merge到最终的minifest中,最终的manifest路径在${module}/build/intermediates/manifests中;
  3. 确定python freeline.py -v与定义在build.gradle中的freeline的版本是否一致;
  4. 确定是否刚刚执行了清空app数据的操作,freeline缓存数据在/data/data路径,清空app数据也会导致连接不上的问题(执行freeline命令时,通常会有句明显的日志反复出现:server result is -1);
  5. 确定是否开启了网络代理导致127.0.0.1被重定向?
  6. 一定要先使用freeline来打全量包,再来进行增量,否则也会出现这个问题。即,freeline的全量编译与android-studio自带的RUN会存在冲突。

当上述问题都无法解决时,有个终极的解决方案就是重启试试...不少人通过重启顺利解决连接不上的问题。。。

后续会通过自动化的方式,尽量避免手工排查上述问题。有遇见相关的问题可以具体描述一下,在issue中进行回复,可以帮忙排查。

@lomanyong lomanyong changed the title Freeline "try to connect device/ connect_device_task failed." 排查方法 问题排查方法:Freeline "try to connect device/ connect_device_task failed." Sep 21, 2016
@moonljt521
Copy link

我的只是偶尔能运行成功,错误的时候日志:
[ERROR] --------------------------------------------------------
[ERROR] Freeline ERROR
[ERROR] --------------------------------------------------------
Please make sure your application is properly running in your device.
Check follow steps:
1. Make sure the versions python freeline.py -v, freeline-gradle and freeline-runtime are the same;
2. Make sure there is no network proxy.
3.
More about this can see: #152
[ERROR] --------------------------------------------------------
[ERROR] Freeline server in app “包名” not found. Please make sure your application is properly running in your device.
[ERROR] --------------------------------------------------------
[DEBUG] Prepare tasks time: 0.5s
[DEBUG] Task engine running time: 16.7s
[DEBUG] Total time: 17.1s
[DEBUG] --------------------------------------------------------

@lomanyong
Copy link
Member Author

@moonljt521 需要先执行python freeline.py -f打全量包安装到设备上,再使用python freeline.py来增量编译。而不是使用android-studio的run,不知是否是这个问题产生的?

以及,issue里提到的那几条是否检查过了呢?

@moonljt521
Copy link

@lomanyong 按您的方式全量和增量编译了, as的freeline 控制台没有报错
不过logcat 报错
java.lang.ClassCastException: com.antfortune.freeline.FreelineApplication cannot be cast to 我的app包名.CrmApp

导致app无法启动

@lomanyong
Copy link
Member Author

@moonljt521 参考一下#159 这个issue可以解决你的问题。

@moonljt521
Copy link

@lomanyong 谢谢回复, #159 么有解决我的问题~

@lomanyong
Copy link
Member Author

@moonljt521 没有解决?

@moonljt521
Copy link

@lomanyong 嗯呢 按照159那条做了配置 仍然是application 类型转换异常

@lomanyong
Copy link
Member Author

@moonljt521clean,然后再重新打包...manifest估计还是旧的,所以问题仍然存在。

@moonljt521
Copy link

@lomanyong 你好,我把配置流程重新做了一遍,现在成功了,除了第一次python.py 需要一分钟外,再次修改都是一两秒就编译好了,多谢

@lomanyong lomanyong changed the title 问题排查方法:Freeline "try to connect device/ connect_device_task failed." [问题排查]Freeline "try to connect device/ connect_device_task failed." Nov 30, 2016
@lomanyong lomanyong changed the title [问题排查]Freeline "try to connect device/ connect_device_task failed." [问题排查] Freeline "try to connect device/ connect_device_task failed." Nov 30, 2016
@ifaint
Copy link

ifaint commented Dec 6, 2016

我现在用的是0.7.3.1(不过其他更新的版本一样有这个问题)。全量可以,如果希望增量,则会报如下错误。之前一直可以,然后就不行了。

[ERROR] --------------------------------------------------------
[ERROR] Freeline ERROR
[ERROR] --------------------------------------------------------
Please make sure your application is properly running in your device.
Check follow steps:
1. Make sure the versions python freeline.py -v, freeline-gradle and freeline-runtime are the same;
2. Make sure there is no network proxy.
3.
More about this can see: #152
[ERROR] -------------

日志反复打印如下:
freeline D/Freeline.LongLinkServer: Freeline.increment server is already running
freeline I/Freeline.Service: onStartCommand Received start id 11, intent: Intent。。。

@lomanyong
Copy link
Member Author

@ifaint 尝试把手机上的 apk 卸载了,然后重新安装试试看

@mambaji
Copy link

mambaji commented Dec 6, 2016

按照上面的操作后还是会出现这个问题
build failed with script: gradlew.bat :app:assembleDebug -P freelineBuild=true --stacktrace

@lomanyong
Copy link
Member Author

@ManbasJi build failed with script: gradlew.bat :app:assembleDebug -P freelineBuild=true --stacktrace出现这个错误就是编译出错了,不是这个问题....往上看看日志,会提示你出错在哪里...

@mambaji
Copy link

mambaji commented Dec 6, 2016

在上面出现了这个
是代码的问题吗
inject: E:\ASproject\TaoDuoDuo\app\build\intermediates\classes\debug\com\qunyu\taoduoduo\mvpview\ZoneView.class
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:191)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:522)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:344)
at com.android.dx.command.dexer.Main.run(Main.java:292)
at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:173)

@lomanyong
Copy link
Member Author

@ManbasJi 恩,就是正常的 gradle 编译出错...按照平时解决 gradle 编译出错的方法去解决就行了...

@WJRye
Copy link

WJRye commented Dec 7, 2016

我的第一次能够连接上设备且提示安装应用程序,但第二次就连接不上了(上面的都排查了)。

@bjzhou
Copy link

bjzhou commented Dec 7, 2016

换手机的时候会出现这情况,希望能够自动执行python freeline.py -f

@zigang
Copy link

zigang commented Dec 18, 2016

只有第一次python freeline.py -f可以连上设备
以后执行python freeline.py就一直提示 [sync_client] try to connect device 10 times...
最后出错,无法连接设备,请问这是怎么回事呢?

@Dragon-Boat
Copy link

确定python freeline.py -v与定义在build.gradle中的freeline的版本是否一致;
定义版本是0.8.4,python freeline -v 是0.8.3 这个怎么处理

@lomanyong
Copy link
Member Author

@Dragon-Boat 升级一下版本,执行gradlew initFreeline -Pmirror

@lomanyong
Copy link
Member Author

@zigang 对照一下上面的方案先检查一下...

@Dragon-Boat
Copy link

@lomanyong ok,另外就算版本不同,运行也没问题。目前macOS和window均已成功;
希望:某些情况下,自动执行-f 全量编译;
偶尔更新代码增量编译后(如pull代码),会出现一些布局文件xml不能正确inflate的错误;全量编译后又正常。

@lomanyong
Copy link
Member Author

@Dragon-Boat 目前其实是有自动全量的,比如说你修改了 build.gradle 或者修改了 AndroidManifest.xml 的情况。在你有超过 20 个文件的改动(通常是 pull 代码的时候),也会自动执行全量编译...

@ifaint
Copy link

ifaint commented Dec 30, 2016

@lomanyong 发现有些手机用不了。我用的moto x style可以。而用的一款华为和小米,就总是不行,运行不起来,提示找不到Application类,这个有办法吗?

@lomanyong
Copy link
Member Author

@ifaint 找不到 application 类的情况可以参考 #273 做下改造

@ligongzixing
Copy link

请问freeLine可以用来运行单元测试吗?还有我发现不能将一个Project下的两个应用同时配置成freeline,会出现initFreeline as a task with that name already exists.

@jk2K
Copy link

jk2K commented Feb 15, 2017

Clean Project 后,再运行 freeline 就可以了

@704480904
Copy link

Freeline 的時候 ,安裝上去之後,白屏的 ,版本號是0.8.6

@lizheng98
Copy link

目前使用0.8.7版本
freeline全量编译是每次都可以正常安装;但是增量编译就报错。

错误日志如下:
[DEBUG] [sync_client] try to connect device 1 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 2 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 3 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 4 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 5 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 6 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 7 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 8 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 9 times...
[DEBUG] [sync_client] wake up Service: d:\Users\Administrator\AppData\Local\Android\sdk\platform-tools\adb.exe shell am startservice -n com.guojiang.meitu.boys/com.antfortune.freeline.FreelineService -e wakeup marker
[DEBUG] [sync_client] try to connect device 10 times...
[DEBUG] [sync_client] Freeline server in app com.guojiang.meitu.boys not found. Please make sure your application is properly running in your device.
[DEBUG] [connect_device_task] connect_device_task finish in 16.9s
[DEBUG] [gradle_sync_task] gradle_sync_task start to run after waiting 16.9s
[DEBUG] [clean_cache_task] clean_cache_task start to run after waiting 16.9s
[DEBUG] [update_stat_task] update_stat_task start to run after waiting 16.9s
[DEBUG] [task_engine] task engine occurs exception, engine will exit.
[DEBUG] [task_engine] it takes task engine 16.93s to execute tasks.
[ERROR] --------------------------------------------------------
[ERROR] Freeline ERROR
[ERROR] --------------------------------------------------------
Please make sure your application is properly running in your device.
Check follow steps:
1. Make sure the versions python freeline.py -v, freeline-gradle and freeline-runtime are the same;
2. Make sure there is no network proxy.

    More about this can see: https://github.com/alibaba/freeline/issues/152

[ERROR] --------------------------------------------------------
[ERROR] Freeline server in app com.guojiang.meitu.boys not found. Please make sure your application is properly running in your device.
[ERROR] --------------------------------------------------------
[DEBUG] Prepare tasks time: 0.3s
[DEBUG] Task engine running time: 16.9s
[DEBUG] Total time: 17.2s
[DEBUG] --------------------------------------------------------

已做了以下排查:
1、确定python freeline.py -v与定义在build.gradle中的freeline的版本一致
2、执行gradlew initFreeline -Pmirror
3、卸载手机上应用,重新全量打包,再增量打包还是出错
4、“”确定FreelineService以及freeline相关组件是否正常merge到最终的minifest中,最终的manifest路径在${module}/build/intermediates/manifests中” 这个怎么检查?

@moonljt521
Copy link

因为问题多多,暂时放弃了使用,回归instant run~

@alonelyshepherd
Copy link

确定FreelineService以及freeline相关组件是否正常merge到最终的minifest中,最终的manifest路径在${module}/build/intermediates/manifests中;

现在确认是这个原因,请问如何解决呢?

@yahier
Copy link

yahier commented May 27, 2017

第一次可以运行,然后修改两个文件,再运行就出现这个错误了
Please make sure your application is properly running in your device.
Check follow steps:
1. Make sure the versions python freeline.py -v, freeline-gradle and freeline-runtime are the same;
2. Make sure there is no network proxy.

@z447924375
Copy link

z447924375 commented Jul 14, 2017

[ERROR] --------------------------------------------------------
[ERROR] Freeline ERROR
[ERROR] --------------------------------------------------------

Error: Unable to access jarfile freeline\release-tools\databinding-cli8.jar

[ERROR] --------------------------------------------------------
[ERROR] process module databinding failed: java -jar freeline\release-tools\databinding-cli8.jar -p com.hubert.hxh -i D:\Androidprojects\WYBN\app\src\main\res -o D:\Androidprojects\WYBN\app\build\freeline\freeline-databinding\app\4dad97da7e097c7fdf84ca39b5beec27\res -d D:
Androidprojects\WYBN\app\build\freeline\freeline-databinding\merged_layoutinfo -c D:\Androidprojects\WYBN\app\build\freeline\freeline-databinding\app\4dad97da7e097c7fdf84ca39b5beec27\java -l false -v 14 -s D:\adsdk
[ERROR] --------------------------------------------------------
总是报关于databing的错误,请问这个怎么解决

@goadsth
Copy link

goadsth commented Jul 19, 2017

0.8.7版本和lizheng98的问题一样,但是昨天用的时候还是能增量编译的,今天各种方法都试过,就是不行。只能暂时回到instant run去了,希望能给出解决方法。

@YanHuiLi
Copy link

请问一下一直是
server result is -1
怎么解决,

@zhouyou123
Copy link

[ERROR] Freeline ERROR
[ERROR] --------------------------------------------------------
Traceback (most recent call last):
File "/Users/zhouyou/Documents/gitProject/odunsmart-android/freeline/freeline_core/task.py", line 123, in execute
self.task.execute()
File "/Users/zhouyou/Documents/gitProject/odunsmart-android/freeline/freeline_core/gradle_clean_build.py", line 74, in execute
output, err, code = cexec(command.split(' '), callback=None)
File "/Users/zhouyou/Documents/gitProject/odunsmart-android/freeline/freeline_core/utils.py", line 28, in cexec
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env, cwd=cwd)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 390, in init
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1024, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

[ERROR] --------------------------------------------------------
[ERROR] unexpected exception within task
[ERROR] --------------------------------------------------------
[DEBUG] Prepare tasks time: 0.2s
[DEBUG] Task engine running time: 0.1s

这个怎么解决?

@jinsen47
Copy link

如果改了freeline{productFlavor ''} 的值, 要重新 ./gradlew checkBCB
不然就不能inc build

@YanHuiLi
Copy link

看下是不是有中文的文件夹,不要使用中文的文件夹

@FivredSeven
Copy link

很奇怪,我每天都用freeline跑的好好的 ,结果今天突然遇到这个问题,不能用了。 楼主提到的这些措施我也都用了,并没有解决,我换了两个手机跑都是这样。
现在我该怎么办?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests