Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Device is connected but 'offline'

This is quite a common question, but none of the solutions appear to work for me. First time asker, so apologies if I get the conventions wrong.

I am trying to connect my Galaxy S5 to my computer running Ubuntu 14.04 so I can do some android development. I have recently downloaded and installed Android Studio and the SDK and my device is detected when it's connected via USB but the device either appears as 'unauthorized' or 'offline'. I know I should be expecting the RSA key prompt but this never appears.

I have tried:

  • Checking debugging was enabled
  • Running adb kill-server and adb devices
  • Restarting (the device, developer options, the machine)
  • Simple unplugging and replugging the USB cable
  • Checking my adb version (it is 1.0.31)
  • Trying different USB ports
  • Revoking USB debugging authorizations
  • Toggling enabling ADB Integration from within Android Studio
  • Connecting as PTP device and MTP device

I have tried it on a separate machine that runs fedora and this works fine with no issues, the promopt appears right away. Therefore I imagine it is not the USB cable that is faulty.

Any ideas?

like image 699
Aaron G Avatar asked Jun 21 '15 13:06

Aaron G


People also ask

Why is my ADB device offline?

If your device is listed with 'offline' next to it, try restarting the device. The ADB daemon on the device will occasionally get hung. I've noticed this more when I've disconnected the cable while LogCat is running and after switching back from connecting via Wi-Fi or Ethernet.

Why is my device not showing in Android Studio?

If your device is not correctly detected in RAD Studio or in the system Device Manager, check the following: Ensure that your Android device is unlocked and not sleeping while connected via USB. Set the appropriate option in Settings or Developer Options. Make sure your Android device is enabled for USB debugging.

Does Android studio require Internet?

Theoretically you can work offline by going to File > Settings > Build, Execution, Deployment > Gradle and checking Offline Work. You will unfortunately have to sync the project while on a working internet connection at least once to have the necessary dependencies downloaded for your project.


2 Answers

Try these:

  • Unplug and replug the USB cable.
  • If it still doesn't work, unplug the USB cable, disable then enable USB debugging in the device settings.
  • If the above two methods fail, reboot the device.
  • If rebooting the device also fails, reboot Android Studio too.
  • If reboot Android Studio still fail, try adb kill-server then adb start-server

Hope this helps.

like image 182
Linh Avatar answered Oct 13 '22 06:10

Linh


Try killing adb adb kill-serverthen disable usb debugging and then start adb by adb start-server then enable usb debugging and plug phone again and huh don't let phone sleep between process

EDIT

There turned out to be a problem with my laptop's ADB RSA key. I'm assuming my G3 was rejecting a bad key and disallowing my laptop to connect to it via ADB.

ADB saves a key file in one of multiple places on a Windows computer, the first is in the location where adb.exe is (C:\android), the second is in the user's >profile (C:\Users*username*.android), the third place is in the Windows system files (C:\Windows\System32\config\systemprofile.android), the file is >simply named "adbkey" with no extension. If there is no key file when ADB runs, it will generate one automatically.

Mine was located in my user folder (C:\Users*username*.android). All I had to do was delete the adbkey file (there was also a file named "adbkey.pub" which >I deleted as well), restart the adb server in command prompt (adb start-server) and plug my phone in. I instantly received the RSA Fingerprint Key window on my >G3 allowing connection between the two devices. Then typing "adb devices" returned my phone's serial number followed by "device" showing it was available. >I went back to the C:\Users*username*.android\ folder and sure enought there were new "adbkey" and "adbkey.pub" files.

got from XDA

EDIT 2

TRY this steps too

  1. Navigate to where .android is stored
  2. open .android and delete file named as adbkey and adbkey.pub
  3. Start ADB then typeadb kill-serverand adb start-server
like image 25
DevUt Avatar answered Oct 13 '22 04:10

DevUt