Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Phone keeps asking to allow Debug USB - Android Studio on Ubuntu Gnome [duplicate]

Tags:

android

adb

I've had to deal with this one a few times and every time I forget what the cause is until I dig deep. So here are the symptoms:

  • Every time you reconnect/reboot the device you get the authorization dialog even though you could swear you checked the Always checkbox the last time.
  • adb shell gives you the blurb below
  • adb devices gives you the other blurb below
  • You cannot connect via adb while in recovery
  • Device is unauthorized and plugging it in won't display the authorization dialog

The adb shell blurb:

user@PC:~$ adb shell
error: device unauthorized.
This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.

The adb devices blurb:

user@PC:~$ adb devices
List of devices attached
C4F124F1B9A98AE unauthorized

Your udev rules are in place and the codes outputted from lsusb are present in your /etc/udev/rules.d/51-android.rules (or the redhat equivalent, if different)

What's happening?

like image 795
copolii Avatar asked Sep 19 '15 19:09

copolii


People also ask

How to enable debug mode in Android Studio?

If you add C and C++ code to your project, Android Studio also runs the LLDB debugger in the Debug window to debug your native code. If the Debug window is not open, select View > Tool Windows > Debug (or click Debug in the tool window bar), and then click the Debugger tab, as shown in figure 1.

How can I run Android apps instead of emulator?

In the Android Studio toolbar, select your app from the run configurations drop-down menu. From the target device drop-down menu, select the device that you want to run your app on. Select Run ▷. This will launch the app on your connected device.


1 Answers

Well, for me, the issue has been what you see below:

user@PC:~$ ls -al ~/.android/
total 20
drwxrwxr-x  3 user    user 4096 Jun  7 15:46 .
drwxr-xr-x 30 user    user 4096 Sep 19 11:30 ..
-rw-------  1 root    root 1704 Jun  7 15:46 adbkey
-rw-r--r--  1 root    root  710 Jun  7 15:46 adbkey.pub
drwxrwxr-x  2 user    user 4096 Jun  7 15:42 cache

Notice how my adbkey and the matching public key are owned by root? The first time I've ran adb anything on this machine has been as root. The fix is easy and you probably already know it: sudo chown user:user ~/.android/adbkey*

like image 170
copolii Avatar answered Oct 11 '22 12:10

copolii