Android Studio - Device is connected but 'offline'

Android StudioAdb

Android Studio Problem Overview


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?

Android Studio Solutions


Solution 1 - Android Studio

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.

Solution 2 - Android Studio

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

Solution 3 - Android Studio

My fix to this issue:

  1. Android settings
  2. Developer options
  3. Revoke USB debugging authorizations
  4. Replug in device and accept authorization as usual.
  5. Profit

Solution 4 - Android Studio

Step 1: Turn off USB DEBUGGING in Developer Options

Step 2: Remove USB Cable

Step 3: Turn on USB Debugging(This rests USB Configurations)

Step 4: on Command Prompt enter adb kill-server and then adb start-server

Step 5: Connect the USB Cable

Step 6: Check Devices connected in Run in Android Studio(you should be able to see your device listed)

Step 7: If you want to continue running using the cable this would be good enough

(If you want to do Wireless Debugging continue with below step)

Step 8: type adb tcpip 5555. If no error is displayed remove USB Cable

Step 9: Look up IP Address of your phone from About abd then type adb connect xxx.vvv.b.n(your phone's IP)

Step 10: Check in Devices in Android Studio again and you shud see you r device in List of devices. If yes,

Solution 5 - Android Studio

If you are on windows and you encountered the same problem, try killing the adb.exe process from task manager and then rerun your app.

Solution 6 - Android Studio

Could not get Samsung Note II (N7100) to connect.

Step 1. Follow answer from user4847410 above. Next time you connect your phone it will come up with an authorisation message and you're in.

Step 2. I also swapped my cable.

Step 3. Check USB port as if you install on one particular port then another port may not be ok for you.

Note: made two batch files

adb-fix.bat

adb kill server
adb start server
pause

adb-devices.bat

adb devices
pause   

-- voted for that correct answer but I don't have enough kudos so it was removed! --

Solution 7 - Android Studio

A shorter cable did the trick.

> It turns out that the wire thickness used inside the cable impacts on the resistance of the cable assembly – this resistance causes energy loss inside the cable when an attached load draws a current, and causes a voltage drop which can reduce the voltage to the end device to a point where it is not possible to charge quickly or completely.

http://goughlui.com/2014/10/01/usb-cable-resistance-why-your-phonetablet-might-be-charging-slow/

Solution 8 - Android Studio

Change the USB cable !!!! I can't explain this technically, however after a lot of trial and error, this what have worked for me.

Solution 9 - Android Studio

To fix this, use USB2 instead of USB3

Solution 10 - Android Studio

I had a long white cable. Just wouldnt stay connected. Switched to another, shorter, black cable and it works 100% of the time.

Solution 11 - Android Studio

Disabling and Enabling the Developer options and debug mode on the Android phone settings fixed the issue.

Solution 12 - Android Studio

Earlier for almost 3hrs I did:

  1. I tried everything given in several sites and my android device never came online.
  2. when I was running adb kill-server and then adb-startserver the "Device File Explorer" on the right bottom of the android studio showed "Device is not online (DISCONNECTED)".

Here is how solve this:

  1. Revoked all USB debugging authorization on the device under "Develop options"
  2. And I added sudo to command "sudo adb kill-server" and then " sudo adb start-server".
  3. After this the message in "Device File Explorer" in android studio changed to "device is pending authentication please accept debugging session on the device". But no message appeared on the device. Tried stopping-restarting adb, connect reconnet usb cable, stop-start usb debugging but nothing worked.
  4. Went back to device and changed the device usb settings from usb charging to "PTP", and, restarted the Android studio. And, boom, the message appeared on the phone to accept the debugging session on device.

Solution 13 - Android Studio

use this command

-> adb disconnect

-> adb connect <ip address for your mobile:port number>

Eg : adb connect 192.168.2.58:5555

Solution 14 - Android Studio

Change your USB Preferences to File Transfer if you use your smartphone to debug.

There are several option :

File Transfer /* Choose this one */

USB Tethering

MIDI

PTP

No Data Transfer

Solution 15 - Android Studio

You can try this:

  1. Go to tools/enable adb integration and uncheck it.

  2. now check it and run again. Next time, android studio will restart adb and it may find your device.

Solution 16 - Android Studio

  • Restart adb by issuing these commands in cmd

    adb kill-server to kill existing adb session

    followed by adb start-server to start a new adb session
  • Disable and re-enable USB debugging on the phone and accept RSA fingerprints if asked by phone
  • Rebooting the phone if it still doesn't work.

If all above don't solve your problem, you may try delete environment variable named "ANDROID_SDK_HOME". It really solved my problem. Hope it Help you!

Solution 17 - Android Studio

This problem is because you have used an old adb version and not support on your device. or you have more than one adb

The key is:

  • make sure you have a latest adb executable on your SDK
  • Make sure to run adb command from "SDK_DIR/platform-tools/" because this should be the latest version (type command "which adb" to check) if u have more than one adb file, you can rename another one.

in my case, on my Windows 7 i have one more adb on "C:\Windows\adb.exe" and its an old version, so my adb command always run from that file. I fixed the problem by running adb form my sdk directory "SDK_DIR/platform-tools/adb.exe"

Solution 18 - Android Studio

On windows--> Launch your terminal from the platform-tools folder inside android sdk.

Then use the following commands

adb kill server
adb start server

it should work

Solution 19 - Android Studio

Solution 20 - Android Studio

Try upgrade your Android SDK Platform as below steps:

  1. Run the SDK Manager

  2. Execute "Install packages…"

  3. Restart the SDK Manager

I tried and it's ok for me.

ref: link

Solution 21 - Android Studio

You maybe having an older version of the ADB, Update the tools package and that should bring down the latest ADB.

Solution 22 - Android Studio

I also recently had this problem and I solved it by rebooting Android Studio. But my friend had to have the original cable for his device, no other cables worked.

Solution 23 - Android Studio

In my case (same problem - that Nexus 5 is connected but with "offline" status) the problem was solved by "Invalidate caches and Restart" in Android Studio. Suppose that problem was in adb and restarting Android Studio causes to adb restart.

Solution 24 - Android Studio

Download and Install your device driver manually through visiting manufacturer website like :Samsung,micromax,intex etc.

Solution 25 - Android Studio

In my case the problem was that I used a USB extension cable. As soon as I plug the microUSB cable right into the PC the device has detected.

Solution 26 - Android Studio

In my case, turned out that you need to be logged as owner of device to properly accept the USB debugging.

Tried the "Disable and re-enable USB debugging on the phone" step but didn't get the RSA prompt on "normal" user, switched to owner and tried again and got it.

Solution 27 - Android Studio

I had this issue on a device with USB-C using a microUSB cable with a USB-C adapter. After switching to a USB-C cable without any adapter it worked. I only saw this issue on a LeEco.

Solution 28 - Android Studio

I tried most of the things on this page and none of them worked for my Samsung S5. However, when I switched the cable to a USB-C type the problem seemed to be solved...until next time.

Solution 29 - Android Studio

Besides the solution mentioned above, try to download Samsung's Android USB Driver for your platform. Here is a link to the Windows one:

https://developer.samsung.com/galaxy/others/android-usb-driver-for-windows

Solution 30 - Android Studio

If your app doesn't manipulate WiFi connections - another slightly different solution, which bypasses USB issues entirely - enabling a wireless debugging connection - ADB over WiFi/TCP/IP.

Solution 31 - Android Studio

Reboot the your mobile this will fix it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAaron GView Question on Stackoverflow
Solution 1 - Android StudioLinhView Answer on Stackoverflow
Solution 2 - Android StudioDevUtView Answer on Stackoverflow
Solution 3 - Android StudioKnossosView Answer on Stackoverflow
Solution 4 - Android StudioN CzarView Answer on Stackoverflow
Solution 5 - Android StudioSammieView Answer on Stackoverflow
Solution 6 - Android Studioalz_OzView Answer on Stackoverflow
Solution 7 - Android StudiopkarcView Answer on Stackoverflow
Solution 8 - Android StudioForrestView Answer on Stackoverflow
Solution 9 - Android StudioKazem MalekiView Answer on Stackoverflow
Solution 10 - Android StudioMike FlynnView Answer on Stackoverflow
Solution 11 - Android StudioFaris MuhammedView Answer on Stackoverflow
Solution 12 - Android StudioAshish GuptaView Answer on Stackoverflow
Solution 13 - Android StudioAkhilView Answer on Stackoverflow
Solution 14 - Android StudioExel StaderlinView Answer on Stackoverflow
Solution 15 - Android StudioKrupal ShahView Answer on Stackoverflow
Solution 16 - Android Studioxiaoqing xuView Answer on Stackoverflow
Solution 17 - Android StudioBamz3rView Answer on Stackoverflow
Solution 18 - Android StudioShubham GoelView Answer on Stackoverflow
Solution 19 - Android StudioRajesh NasitView Answer on Stackoverflow
Solution 20 - Android StudioKhoa PhungView Answer on Stackoverflow
Solution 21 - Android StudioDiceyusView Answer on Stackoverflow
Solution 22 - Android StudioNataliaView Answer on Stackoverflow
Solution 23 - Android StudioAnton VaysbergView Answer on Stackoverflow
Solution 24 - Android StudioRaghav BView Answer on Stackoverflow
Solution 25 - Android StudiokkocsisView Answer on Stackoverflow
Solution 26 - Android StudioHonzaView Answer on Stackoverflow
Solution 27 - Android StudioonoView Answer on Stackoverflow
Solution 28 - Android StudioDaleBView Answer on Stackoverflow
Solution 29 - Android StudioMehdi BoukhechbaView Answer on Stackoverflow
Solution 30 - Android StudionsandersenView Answer on Stackoverflow
Solution 31 - Android StudioDivyaadzView Answer on Stackoverflow