5

adb connects to my device (Xiaomi Redmi 4, MIUI 11.0.2, Android 7.1.2) just fine via USB as well as via WiFi. However, I've had no success trying to connect flutter. Flutter does detect my device when I connect via USB but doesn't prompt for an Authorization dialog:

$ flutter doctor

Doctor summary (to see all details, run flutter doctor -v):                                                                             
[✓] Flutter (Channel beta, v1.14.6, on Linux, locale en_US.UTF-8)                                                                       
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Android Studio (version 3.6)                                                                                                        
[!] Connected device                                                                                                                                                                                        
! Doctor found issues in 1 category.

$ flutter devices                                                                                                                         
No devices detected.                                                                                                                    

Run 'flutter emulators' to list and start any available device emulators.                                                               

Or, if you expected your device to be detected, please run "flutter doctor" to diagnose potential issues, or visit                      
https://flutter.dev/setup/ for troubleshooting tips.                                                                                    

• Device 9fd66a407d14 is not authorized.                                                                                                
You might need to check your device for an authorization dialog. 

I've tried

  • adb kill-server and adb start-server along with disconnecting and reconnecting my device
  • Revoking USB Debugging authorizations from my phone
  • Disabling and renabling USB debugging from my phone
  • Restarting my phone

but flutter still says that my device is not authorized.

Is there a solution for this?

Spikatrix
  • 20,225
  • 7
  • 37
  • 83

4 Answers4

3

I had another issue with adb in which when I connect to my device via USB or WiFi, it would prompt me for authorization even after I check "Always allow from this computer" (This was the case for more than a year and I never really knew why)

Turns out that was because I had ~/.android/adbkey owned by the root user. So as a normal user, adb won't be able to write to that file which means that it wouldn't be able to remember devices. I solved that with the steps in this answer:

As described in this issue, this can happen if you run adb for the first time as root. It creates a key file on your computer owned by the root user, so your normal user account can't read or overwrite it.

To check if this is the case:

$ ls -l ~/.android/adbkey
-rw------- 1 root root 1708 Nov 13  2012 .android/adbkey
             ^ notice root here

To fix it:

$ sudo chown $USER: ~/.android/adbkey
$ ls -l ~/.android/adbkey
$ -rw------- 1 thomas thomas 1708 Nov 13  2012 /home/thomas/.android/adbkey
               ^ now shows your username and primary group

Finally, restart the adb server:

$ adb kill-server
$ adb start-server

Once I solved that, Flutter worked perfectly!

Spikatrix
  • 20,225
  • 7
  • 37
  • 83
3

As Mr Darish suggested... Settings -> Additional settings -> Developer options --> Revoke USB Debugging and Disconnect your device(This removes previous authorization and ask for new) .

But sometimes it does not work. So just go to Settings -> Additional settings -> Developer options -> Select USB configuration -> Select Charging option there. And it will show autorization dialog.

Sachin Soma
  • 3,432
  • 2
  • 10
  • 18
1

You can try revoking USB RSA fingerprints and reconnecting.

Here you go.

Settings -> Additional settings -> Developer options --> Revoke USB Debugging and Disconnect your device.

After reconnecting, you will get a RSA Fingerprint verification window, click on accept. Done.

Note: If your phone has configured for multiple user accounts, make sure you are on the main user account (administrator).

Darish
  • 11,032
  • 5
  • 50
  • 70
  • I did try this once as said in the question, but it still did not prompt me for authorization – Spikatrix Mar 06 '20 at 12:20
  • @Spikatrix In linux, did you try changing usb mode to transfer photos (PTP) ?? – Darish Mar 06 '20 at 12:32
  • Yes, I did try that as well as file transfer mode with no success – Spikatrix Mar 06 '20 at 14:46
  • `flutter emulators` does show up all 3 of my installed emulators although I haven't tried flutter apps on them. I want to install flutter apps on my device rather than on an emulator the primary reason being I only have 8 GB of RAM and emulators suck up a ton of RAM. Also, do you mean install a flutter debug apk? – Spikatrix Mar 11 '20 at 08:13
  • Just transferred the sample flutter app APK to my device and installed it and it works just fine. Also, I can install it directly on an Android emulator via Android Studio and it works as well. My device doesn't show up in Android Studio because it isn't authorized – Spikatrix Mar 11 '20 at 08:49
  • connect your device using usb, then run $adb tcpip 8080 – Darish Mar 11 '20 at 11:02
  • then disconnect the usb cable. After that, run $adb connect yourDeviceIpAddress:8080 – Darish Mar 11 '20 at 11:03
  • make sure that both of your device and laptop are under same wifi connection. what output do you got? – Darish Mar 11 '20 at 11:04
  • 1
    I finally [solved the issue](https://stackoverflow.com/a/60636267/3049655). Thanks for your help though! – Spikatrix Mar 11 '20 at 12:42
0

I am using windows 10, I don't think it helping you directly, I just want to share how my problem solved and may help someone out there

using android studio - find menu tools > sdk manager

at sdk manager find -> Appearance & Behavior | System Settings | Android SDK at android sdk find SDK Tools Menu and Install Google USB Driver

at Device Manager (Win + R -> devmgmt.msc) install Google USB Driver for the adb (in my case my phone is installed already and I update the driver).

after that we have to connect out phone and trust the computer (I suggest to turn on usb debugging first and revoke all usb debugging permission in developer option)

Duman
  • 1
  • 1