简体   繁体   English

Android Studio无法通过OSX上的ADB连接

[英]Android studio can't connect through ADB on OSX

I've been working a bit with Android Studio on OSX 10.7.5 and it looks very promising. 我已经在OSX 10.7.5上使用Android Studio了,它看起来非常有前景。 I've run into a problem when trying to launch an application on my device however. 我尝试在我的设备上启动应用程序时遇到了问题。

When clicking the run button, AS claims to be "waiting for ADB". 单击运行按钮时,AS声称“正在等待ADB”。 After a while it times out and says that "ADB is not responding...". 过了一会儿,它超时并说“亚行没有回应......”。

I've tried rebooting and restarting adb with adb-killserver and adb-startserver many times but it won't connect. 我尝试过多次使用adb-killserveradb-startserver重新启动并重新启动adb,但它无法连接。 When running adb devices or launching through eclipse, all works fine. 当运行adb devices或通过eclipse启动时,一切正常。

Anyone got ideas, I would be very grateful! 任何人都有想法,我将非常感激!

On the OS X the following steps solved my problem: 在OS X上,以下步骤解决了我的问题:

  1. Disconnect your Android devices; 断开Android设备的连接;
  2. Quit Android Studio; 退出Android Studio;
  3. Force Quit process 'adb' from the Activity Monitor; 从活动监视器强制退出进程'adb';
  4. Start Android Studio. 启动Android Studio。

I found the problem when I using the genymotion. 我在使用genymotion时发现了这个问题。 At last, I realized the problem is that the adb location is not the same as the android studio. 最后,我意识到问题是adb位置与android studio不同。 So you should update the adb of your genymotion. 所以你应该更新你的genymotion的adb。 The step: Genymotion settings -> ADB -> Use custom Android SDK tools 步骤:Genymotion设置 - > ADB - >使用自定义Android SDK工具

设置图像

I just had the same problem with Android Studio 0.5.3. 我刚刚在Android Studio 0.5.3中遇到了同样的问题。 I would recommend restarting your computer, if the adb kill-server, adb start-server method doesn't work. 我建议重新启动计算机,如果adb kill-server,adb start-server方法不起作用。

我刚刚在我的Mac Mini上发生了这种情况,当我将电缆插入背面的另一个USB端口时,它最终工作(识别Nexus 5)...

In order to get my application running on a device, I needed to edit the run configuration for the app by going into the Run menu and selecting Edit Configurations . 为了让我的应用程序在设备上运行,我需要通过进入“ 运行”菜单并选择“ 编辑配置”编辑应用程序的运行 配置

I selected the configuration that had my app's name and changed the Target Device to USB Device which then allowed me to run the app from a device. 我选择了具有应用程序名称的配置,并将目标设备更改为USB设备 ,然后允许我从设备运行应用程序。 Beforehand I was getting similar behavior to what you describe. 事先我得到了与你描述的相似的行为。 It is possible yours is an entirely different issue :( 你的可能是一个完全不同的问题:(

I had the same thing happen. 我有同样的事情发生。 As soon as I unplugged my device, the "Waiting for ADB" notification disappeared and it worked. 一旦我拔下我的设备,“等待亚行”通知就消失了,并且有效。 I guess you can't start AS when a device is plugged in. 我想你插入设备时无法启动AS。

Span said that you should do strange things, but sometimes it works (strange = reinstall, reboot using word 'maybe'). 斯潘说你应该做一些奇怪的事情,但有时它会起作用(奇怪=重新安装,重启使用'可能'字样)。 We should understand that it could be, because of some bad settings in OS which had been changed, but you do not remember about it. 我们应该理解它可能是,因为操作系统中的一些不良设置已被更改,但你不记得它。

But my case was even stranger! 但我的情况甚至更奇怪! :) :)

Cause Windows do not limit you to have many Firewalls it could be the key! 因为Windows不限制你有许多防火墙它可能是关键! Firewalls might not permit some apps to connect withother, you should check also it. 防火墙可能不允许某些应用程序与其他应用程序连接,您也应该检查它。

I described it in: here 我在这里描述:

Assuming the crash course to start Android Studio: 假设启动Android Studio的速成课程:

  • disable connection to internet (for security), 禁用与互联网的连接(为安全起见),
  • uninstall Android Studio, 卸载Android Studio,
  • remove .gradle and .AndroidStudio folder from your home directory, 从主目录中删除.gradle和.AndroidStudio文件夹,
  • remove all firewalls right way, reinstall & set them up to allow, 正确删除所有防火墙,重新安装并设置它们以允许,
  • remove all av's the same as above, 删除所有与上面相同的,
  • check Windows internal firewall (or iptables in Linux :) ), 检查Windows内部防火墙(或Linux :)中的iptables),
  • install Android Studio. 安装Android Studio。

If it do not work and you want to have your OS not reinstalled - make VM with Windows and try. 如果它不起作用并且您希望不重新安装操作系统 - 使用Windows制作VM并尝试。 If not work - reinstall system :( 如果不行 - 重新安装系统:(

Regards. 问候。

EDIT: This actually solved my issue so this is the accepted answer. 编辑:这实际上解决了我的问题所以这是接受的答案。 It seems this answer also helps alot of people but it did not work for me. 似乎这个答案也有助于很多人,但它对我不起作用。

Here's what I did to finally make it work. 这就是我最终做到的工作。 No idea which of these steps triggered my working copy as it seemed very random but I will put them in order. 不知道这些步骤中的哪一个触发了我的工作副本,因为它似乎非常随机但我会把它们整理好。

  1. Uninstall AS 卸载AS
  2. Remove old path to adb from bash 从bash中删除adb的旧路径
  3. Turn off firewall (or at least monitor which connections are being made by AS and various USB drivers and allow them) 关闭防火墙(或至少监控AS和各种USB驱动程序正在建立的连接并允许它们)
  4. Install AS 安装AS
  5. Change target device under Run -> Edit configurations 在运行 - >编辑配置下更改目标设备
  6. Launch 发射
  7. It works...maybe! 它有效......也许! ... ... ......
  8. Change theme 改变主题
  9. Reboot 重启
  10. Doesn't work 不行
  11. Unplug and plug in device 拔下并插入设备
  12. Should work, if not try rebooting and unplugging/plugging until it does. 应该工作,如果没有尝试重新启动和拔出/插入,直到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM