Flutter does not prompt the device for an authorization dialog
Asked Answered
W

4

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?

Worker answered 3/3, 2020 at 12:22 Comment(6)
Once i faced this issue with huawei phone and restarting it fixed the problem.Steady
@P4yam Forgot to mention that I've also done that but it still does not prompt meWorker
which OS are you using? windows?Ballentine
@Ballentine I'm on LinuxWorker
Try connecting the device in 'File Transfer' mode. Basically any other mode than 'Charging'. Also you can try running the command adb reconnect offline to try to reconnect to offline/unauthorized devicesCritta
@SiddharthPatankar Couldn't get it to work. adb works just fine. It's flutter that doesn't seem to prompt for an authorization dialog. And I've tried adb reconnect offline but that doesn't seem like a valid commandWorker
W
4

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!

Worker answered 11/3, 2020 at 12:39 Comment(0)
F
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.

Fado answered 12/3, 2020 at 8:48 Comment(0)
B
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).

Ballentine answered 6/3, 2020 at 9:18 Comment(9)
I did try this once as said in the question, but it still did not prompt me for authorizationWorker
@Worker In linux, did you try changing usb mode to transfer photos (PTP) ??Ballentine
Yes, I did try that as well as file transfer mode with no successWorker
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?Worker
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 authorizedWorker
connect your device using usb, then run $adb tcpip 8080Ballentine
then disconnect the usb cable. After that, run $adb connect yourDeviceIpAddress:8080Ballentine
make sure that both of your device and laptop are under same wifi connection. what output do you got?Ballentine
I finally solved the issue. Thanks for your help though!Worker
D
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)

Darvon answered 30/3, 2020 at 14:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.