Android Studio 认为物理设备为 Null?

我一直在开发一个 Android Application for Android(SDK 最小版本14) ,我有正常测试它与平板电脑,如 Samsung Galaxy 2 and Nexus 7。 然而,当我尝试运行应用程序(通过点击运行在 AndroidStudio) ,AS 不能识别平板电脑的信息,如下图所示。

Device is Null

有趣的是,如上图所示,当设备 sdk 的 Android 版本是 4.2.2时,AS 也将其检测为 API 1 平板电脑已经设置为接受“ USB debugging”的开发选项,我已经尝试重新启动平板电脑,并重新启动 AS,但我仍然得到相同的问题(一切与 nexus 7 and Samsung Galaxy 2)。

我正在研究的平板/设备是一个“非常酷”的 T742

Environment information:
OS: ubuntu
AndroidStudio version: 0.8.6


Tablet Android version:4.2.2
Tablet Kernel version: 3.4.5
App min SDK: 14
39783 次浏览

Ok So I finally found the problem, apparently on this device you have to set to connect as camera(even after usb debugging is already enabled)

enter image description here

Also this link describes the setting up process

Sometimes in Linux (Centos 6 in my case) the reason can be that you didn't started Android Studio as the root user. please restart android studio as the root user and try it!

Ran into the same problem while using Android Studio on Ubuntu. Apparently for me the fix was to set the USB connection mode for the device as MTP.

I've seen this error a few times when adb hasn't been connected with correct permissions.

On the terminal try

~/Android/Sdk/platform-tools> ./adb devices

if it returns

<deviceIdentifier> no permissions

then you need to restart adb with correct perms

~/Android/Sdk/platform-tools$> ./adb kill-server
~/Android/Sdk/platform-tools$> sudo ./adb devices

if that worked then you'll get

List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
<deviceIdentifier>  device

No more Sdk version resolution issues in Android Studio after that.

Disabling and re-enabling debugging while the device was connected did the trick for me.

I had the same problem.

I solved it by opening my Android device Settings, then selecting "Turn off" then "Turn on" for USB Debugging.

First check adb version:If it gives Output like

Android Debug Bridge version 1.0.32

Then just restart the daemon.

sudo adb kill-server
sudo adb start-server

else install adb first and restart the daemon Worked for me, in ubuntu 16.04.3

For ubuntu machine select the transfer option and device will detected in android studio as well as for debugging. Generally device is at charging state for windows but for ubuntu this is how it works.

Also many a times device is not detected , do the same thing again.

On Ubuntu, with my Pixel XL on 8.0, I had to do this while plugged into computer:

Settings -> Connected Devices -> USB --> Change to 'Transferring Files'

Needed MTP mode, but it does not come up under the USB side. In the storage setting on the menu bar item you get to set the PC connection type as ... MTP.

Just run this command after you connect your device to your Ubuntu system:

adb devices

This works for me.

Note: Make sure you have selected file transfer option in your phone.

Have the same problem with my Nexus 5/5X/Pixel 2 XL on Ubuntu 18.04.

A permanent solution is to add a udev rule so that you can always access the device.

  • Find your device with the command lsusb. This outputs e.g. for my Pixel 2 XL this:

    Bus 001 Device 003: ID 18d1:4ee7 Google Inc.
    
    
    # This means: BUS=001, DEVICE=003, VENDOR=18d1, PRODUCT=4ee7
    
  • Now check the permissions. Replace 001 and 003 with your parameters:

    ls -l /dev/bus/usb/001/008
    
    
    # Output: crw-rw-r-T 1 root root 189, 8 Nov 10 18:34 /dev/bus/usb/001/003
    # Unless you are root, you are missing the permissions to access the device
    
  • To fix this, create a udev rule file with sudo nano /etc/udev/rules.d/51-android.rules with the following content:

    SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", MODE="0660",
    GROUP="plugdev", SYMLINK+="android%n"
    
    
    # You need to replace "18d1" and "4ee7" with your output of `lsusb` above
    
  • Unplug and plug you device back in. It should now always be recognized. If not, restart the adb server a last time with adb kill-server.

Source: http://www.janosgyerik.com/adding-udev-rules-for-usb-debugging-android-devices/

check processes running, i had several adb processes running and i think this was screwing things up for me. Kill them all then restart Studio. HTC Sync Manager, GenyMotion etc and possibly when you have multiple Android Studio windows open can result in multiple conflicting adb processes.

Recently, I was facing the same issue for Vivo and MI phones. I have tried everything described in this thread. I tried connecting as MTP, PTP; But nothing worked.

After many retries I found a solution for my case and may be it can help others too.

  1. Open terminal window in Android Studio
  2. Kill ADB server using following command: adb kill-server
  3. Restart ADB server using following command: adb start-server

It solved my issue.

On ubuntu installing adb worked for me, I think there was some problem with default android studio one .

In terminal use command

sudo apt install adb

On Ubuntu especially or any other platform. Please and Please Check your adb version. I can't stress this enough. ensure it is updated or the lastest version especially if the above answers doesn't work and this link also does not work.

After I updated my platform-tools folder located at

PATH_TO/Android/Sdk/platform-tools

which also contains the adb it worked. I ran
adb devices

first it would show unauthorized then

you unplug and re-plug the android device. Then your phone would ask for permission before the system would read your device.

I had the same problem. I resolved this by doing

  1. Android -> SDk -> platform tool

2.Open terminal for(ubuntu user) or open cmd(window user)

3.type command "sudo adb kill-server"

4.Go to android studio,then reconnect the device.

Go to terminal in android studio and run "adb devices". It will show the connected devices. Then Run the app and the device should show up.

In my case, simply looking at my phone and ticking the pop-up checkbox to allow USB debugging did the job for me.