Java 找不到目标设备 android studio 2.1.1

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37499118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:23:06  来源:igfitidea点击:

no target device found android studio 2.1.1

javaandroidandroid-studioubuntu-14.04usb-debugging

提问by Adithya

i'm using android studio 2.1.1in ubuntu 14.04.Now my question is,i want to run the program through my phone without emulator. so i chose the target as usb device but whenever i run this,below mentioned error is rasing.

我在 ubuntu 14.04 中使用android studio 2.1.1。现在我的问题是,我想在没有模拟器的情况下通过我的手机运行程序。所以我选择了目标作为 USB 设备,但是每当我运行它时,下面提到的错误就会出现。

Error running app : No target device found.

运行应用程序时出错:找不到目标设备。

i checked my device by using adb devicescommand in terminal. adithya@adithya-Lenovo-B460e:~$ adb devices List of devices attached 59V8I7HEJJWGGMK7 device

我在终端中使用adb devices命令检查了我的设备。adithya@adithya-Lenovo-B460e:~$ adb devices 附加设备 列表 59V8I7HEJJWGGMK7 设备

i also tried with selecting of MTP & PTP.but nothing worked out. kindly anyone help me to solve this problem..

我也尝试过选择 MTP 和 PTP。但没有任何效果。好心人帮我解决这个问题..

采纳答案by Jeremie

I already had this problem before.

我之前已经遇到过这个问题。

Choose "Run" then "Edit Configurations". In the "General" tab, check the "Deployment Target Options" section.

选择“运行”,然后选择“编辑配置”。在“常规”选项卡中,选中“部署目标选项”部分。

In my case, the target was already set to "USB Device" and the checkbox "Use same device for future launches" was checked.

就我而言,目标已设置为“USB 设备”,并且选中了“使用相同设备进行未来启动”复选框。

I had to change the target to "Show Device Chooser Dialog" and I unchecked the check box. Then my device appeared in the list.

我不得不将目标更改为“显示设备选择器对话框”并取消选中该复选框。然后我的设备出现在列表中。

If your device still doesn't appear, then you have to enable USB-Debugging in the smartphone settings again.

如果您的设备仍然没有出现,那么您必须再次在智能手机设置中启用 USB 调试。

回答by Adithya

After i changed my target to usb. i had to create the file /etc/udev/rules.d/51-android.rules with vendor details .Click for Solution

在我将目标更改为 USB 之后。我必须使用供应商详细信息创建文件 /etc/udev/rules.d/51-android.rules 。点击解决方案

回答by dvrm

trick that works for me when target device not found:

找不到目标设备时对我有用的技巧:

  • click the "attach debugger to android process" button. (that will enable adb integration for you)

  • click the run button

  • 单击“将调试器附加到 android 进程”按钮。(这将为您启用 adb 集成)

  • 点击运行按钮

回答by WhiteSnake

Note: I had problem on Windows 7 but it might help you as well..

注意:我在 Windows 7 上遇到了问题,但它也可能对您有所帮助。

I had problem with android studio detecting my phone(Acer Liquid Zest 4G), tried restarting android studio, switching back and forth between PTP and MTP, OS was able to detect device normally.

我在 android studio 检测我的手机(Acer Liquid Zest 4G)时遇到问题,尝试重新启动 android studio,在 PTP 和 MTP 之间来回切换,操作系统能够正常检测到设备。

So what I did was, in Developer Options i enabled USB debugging, USB connection is in PTP mode, then from phone manufacturer's site (you can find site for your phone here: https://developer.android.com/studio/run/oem-usb.html), I downloaded USB driver for my phone model, installed driver and android studio was able to detect my phone(there was no need for restart).

所以我所做的是,在开发人员选项中,我启用了 USB 调试,USB 连接处于 PTP 模式,然后从手机制造商的网站(您可以在这里找到您手机的网站:https: //developer.android.com/studio/run/ oem-usb.html),我为我的手机型号下载了 USB 驱动程序,安装了驱动程序并且 android studio 能够检测到我的手机(不需要重新启动)。

I will repeat again, you must have USB Debugging enabled in Developer Options, otherwise it won't work. Hope it helps.

我再重复一遍,您必须在开发人员选项中启用 USB 调试,否则将无法正常工作。希望能帮助到你。

回答by utsav_deep

If you are using 32-bit ubuntu (my case) then it is most likely that Android Studio has downloaded 64-bit version of adband fastbootinside your sdk/platform-toolsfolder. I think you already have installed adb (and fastboot). If you haven't then run these commands in terminal:

如果您使用的是32位的Ubuntu(我的情况),那么它是最有可能的是Android Studio中已下载的64位版本adbfastboot您的内部sdk/platform-tools文件夹。我认为您已经安装了 adb(和 fastboot)。如果还没有,请在终端中运行这些命令:

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot

This will install 32-bit version of adband fastboot. Now just replace the 64-bit adband fastbootexecutable files in sdk/platform-toolswith the installed 32-bit versions:

这将安装 32 位版本adbfastboot. 现在只需将 64 位adbfastboot可执行文件sdk/platform-tools替换为已安装的 32 位版本:

cp /usr/bin/adb <path-to-your-adt-sdk-package>/sdk/platform-tools/adb
cp /usr/bin/fastboot <path-to-your-adt-sdk-package>/sdk/platformtools/fastboot

Now your android studio should be able to run your App in your device.

现在你的 android studio 应该可以在你的设备上运行你的应用了。

回答by Basant

go to "Run>edit configuration>" and select "Open select deployment target dialog" from deployment target option then run your app it will show you a dialog box you can choose your target device from there, enjoy it.

转到“运行>编辑配置>”并从部署目标选项中选择“打开选择部署目标对话框”,然后运行您的应用程序,它将显示一个对话框,您可以从那里选择目标设备,尽情享受吧。

回答by Jonathan Starr

I had the same thing on Windows 7 where I had the device properly set and the driver installed, and I was routinely running on the device. Then suddenly I started getting this error every time. I opened the Edit Configurations dialog as described above, switched to an emulator, tried one run, then went to the same dialog and changed back to USB. Then if worked again.

我在 Windows 7 上有同样的事情,我正确设置了设备并安装了驱动程序,并且我经常在设备上运行。然后突然我每次都开始收到这个错误。我如上所述打开“编辑配置”对话框,切换到仿真器,尝试运行一次,然后转到同一个对话框并改回 USB。然后如果再次工作。

回答by Sheshank Kodam

I have used a different USB cable and it started working. This is weird because the USB cable (which was not detected in android studio) was charging the phone. This made me feel like there was a problem on my Mac.

我使用了不同的 USB 电缆,它开始工作。这很奇怪,因为 USB 电缆(在 android studio 中未检测到)正在为手机充电。这让我觉得我的 Mac 有问题。

However changing the cable worked for me. Just check this option as well if you got stuck with this problem.

然而,改变电缆对我有用。如果您遇到此问题,也只需选中此选项。

回答by Developer

  1. Set up a device for development https://developer.android.com/studio/run/device.html#setting-up

  2. Enable developer options and debugging https://developer.android.com/studio/debug/dev-options.html#enable

  1. 设置用于开发的设备https://developer.android.com/studio/run/device.html#setting-up

  2. 启用开发者选项和调试 https://developer.android.com/studio/debug/dev-options.html#enable

Optional

可选的

  1. How to enable Developer options and USB debugging
    • Open Settings menu on Home screen.
    • Scroll to About Tablet and tap it.
    • Click on Build number for seven times until a pop-up message says “You are now a developer!”
  1. 如何启用开发人员选项和 USB 调试
    • 在主屏幕上打开设置菜单。
    • 滚动到关于平板电脑并点击它。
    • 单击内部版本号七次,直到弹出消息显示“您现在是开发人员!”

回答by Josh Chappelle

I had this problem after upgrading from Android Studio 2.3 to 3.0. As simple as it sounds, I actually just restarted my phone to fix it.

从 Android Studio 2.3 升级到 3.0 后,我遇到了这个问题。听起来很简单,实际上我只是重新启动了手机来修复它。

My guess is that the adb server on the phone somehow cached something from the previous installation of android studio, maybe a connection object or something, and by restarting the adb server it resolved the issue.

我的猜测是手机上的 adb 服务器以某种方式缓存了之前安装的 android studio 中的某些内容,可能是连接对象或其他内容,然后通过重新启动 adb 服务器解决了该问题。

I hope this helps someone.

我希望这可以帮助别人。