Flutter does not prompt the device for an authorization dialog

2,353

Solution 1

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!

Solution 2

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.

Solution 3

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).

Share:
2,353
Spikatrix
Author by

Spikatrix

Just a guy who loves programming. I love to build awesome applications and games. I've fiddled around with C, Java, Javascript, Typescript, HTML5, CSS3, Python 3, Vue, React, Android Development, Game Development and several other stuff. Still exploring new technologies. I use Arch, btw

Updated on December 18, 2022

Comments

  • Spikatrix
    Spikatrix over 1 year

    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
    Spikatrix over 4 years
    I did try this once as said in the question, but it still did not prompt me for authorization
  • Darish
    Darish over 4 years
    @Spikatrix In linux, did you try changing usb mode to transfer photos (PTP) ??
  • Spikatrix
    Spikatrix over 4 years
    Yes, I did try that as well as file transfer mode with no success
  • Spikatrix
    Spikatrix over 4 years
    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
    Spikatrix over 4 years
    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
  • Darish
    Darish over 4 years
    connect your device using usb, then run $adb tcpip 8080
  • Darish
    Darish over 4 years
    then disconnect the usb cable. After that, run $adb connect yourDeviceIpAddress:8080
  • Darish
    Darish over 4 years
    make sure that both of your device and laptop are under same wifi connection. what output do you got?
  • Spikatrix
    Spikatrix over 4 years
    I finally solved the issue. Thanks for your help though!