Flutter plugin: Android studio doesn't detect connected devices - android-studio

It shows and when clicked a drop down always shows "Loading...", but nothing ever gets detected.
Even though adb detects the device.

Setting the correct path for "Flutter SDK path" under "Languages & Frameworks/Flutter" in Android Studio settings fixed the problem.
I had installed two flutter copies, the old one was dirty and not working. But I hadn't updated the path for the new copy in Android Studio.
Edit
It's always good to run flutter doctor, when in doubt.

I had the same issue - make sure you enable USB Debugging in Developer Options on your device

I had the same problem, but it was solved reformating my pubspec.yaml file (I had a identation issue)

I had the same issue and none of the comments posted here helped me. After trying many things, I noticed that I had an unstable flutter version by running flutter version, I changed then to a stable version (at the time this post was written it was version 1.17.3) by executing flutter version 1.17.3, then I restarted android studio and flutter finally had recognised my device

you just need to set your android sdk path for the flutter using this command :
flutter config --android-sdk /path/to/Sdk
and you can get your sdk path(/path/to/Sdk) using this command :
echo $ANDROID_HOME

Related

Flutter is not being recognized on the machine

I formatted my computer and installed windows 10 again because I wanted to play and Linux was having problems.
I am trying to install flutter and dart for application development, but he is accusing this error.
Flutter doctor
I tested it before changing the flutter to beta and it recognized the flutter and dart plugins, however I want to leave it in the stable channel.
However, my code doesn't recognize it, I believe it is because of these errors with the flutter and dart plugins.
Code
I already installed the plugins through android studio and also vscode.
I tried to uninstall and install again, restart the computer, set path ...
I managed to solve it, I will leave here the solution for those who had the same problem as me.
I changed the channel to the Master and ran a flutter upgrade.
Now everything is running smoothly.
Maybe some bug with the stable channel, I can't say.
So:
Flutter channel master
Flutter upgrade
VOILÁ
Flutter doctor
Did you install flutter plugin in android studio properly? (Recheck in android studio.)
if yes then remove it and reinstall it.
if (1) not working then update your android studio.
keep your flutter sdk in c drive
if still flutter cannot trace plugin then set flutter sdk and dart sdk manually in android studio.
for dart
for flutter

Android Studios error : Unable to locate adb location

I'm new to Android Studios. After trying to press play on my Pixel 3a device emulator on AVD Manager this pops up. Error Message : Unable to locate adb
However my emulator runs just fine, I just can't run the "flutter run" command and the flutter app on the emulator. Emulator
I'm on Android Studios 4.0. Here's what I've tried so far to solve this issue.
AVG Antivirus
I added the adb.exe path in the exception section of my antivirus. AVG Antivirus
Android SDK Location
I went to SDK Manager, pressed edit beside the Android SDK Location box. All SDK components are already updated. Android SDK LocationUpdated SDK Components
SDK Platform Tools
I unchecked and checked SDK Platform Tools on SDK Tools.
Platform Tools
I've tried everything but still no luck. It's been a week and it's getting really annoying. I really do hope someone can help me. Really much appreciate it. Thanks in advance 😊
I've been tearing my hair out about this since I updated to v4.0 about an hour ago! :) This is what worked for me in the end (the other solutions about stopping starting adb server etc. just didn't work at all). YMMV.
Go into SDK manager, and uninstall :
Android Emulator
SDK platform tools
SDK command line tools
Close SDK manager and/or android studio completely.
Make sure the directories for these tools under AppData/ .. /Sdk have all been removed properly. Just zap them if they haven't.
Restart Android Studio and re-install all these packages.
I did another stop/restart after this, just to be sure.
Step 3: Profit!
Seems that upgrading the existing packages maybe didn't work properly, even if AS thought it did.
Still seem to be having issues using the geolocator package now (which was working fine before, so thinking this is setup too), but the emulator is starting OK now with no adb issues.
I tried reinstalling Android SDK after deleting the platform-tools dir but with no success. What did work for me were the following steps:
In Android Studio go to File > Project Structure (Ctrl + Alt + Shift + S in windows);
Under Project Settings>Project>Project SDK must have a valid Android SDK selected;
emulate a new device;
check if the adb daemon is running and recognizes the emulated device: open cmd prompt, run %ANDROID_HOME%\platform-tools\adb.exe devices and it should list the device you have on atm.
If you already have installed the Sdk tools at ~/Android/Sdk, you can add this to your .bashrc or .zshrc, alias adb=/home/USER/Android/Sdk/platform-tools/adb (change USER to your user) and restarting android studio, not invalidate caches/restart but closing it and re-opening it, which should pick the new adb alias from the shell.
The answers didn't work for me. So I removed/uninstalled everything and install a new android studio.
How to remove android studio correcly:

Android Studio 3.6 : Unable to run apk on emulator or device

After Updating Android Studio to the version 3.6, I am unable to install an app directly to device by using Run button.
It just updates the gradle and shows gradle updated popup that's it.
I tried invalidating cache and recreating the emulator device but no luck yet.
Let me know if anyone could help as am creating APK and installing it manually in emulator.
I have installed the Android Studio 3.6 and suddenly existing project stopped running. I tried the following thing and it worked.
Android Studio -> Run -> Edit Configurations -> Installation options -> Select Nothing instead of Default apk.
I am not able to post this as comment, but maybe someone finds this info useful.
I faced same problem after updating Android Studio to 3.6.1 on Mac OS.
I tried to use gradle task for installing and launching my application and I found strange log in console about missing adb in platform-tools folder.
So, as result: after update folder platform-tools was moved into folder with same name (was: sdk/platform-tools become: sdk/platform-tools/platform-tools). I just move it manually back and everything is worked as a charm.
Hope it helps.
I have installed Android Studio 3.6 yesterday. I have tried both way to install APK.
Directly by Run button. [DEVICE - Working, Emulator - Working]
Generated APK, Drag and Drop to Emulator. (Its also working)
Hope It will work for you too. Just drag n drop APK file to emulator.
Bonus - May your emulator is older, You can update your Emulator from
SDK Manager and Create New.

Not able to connect adb after upgrate Android Studio to 3.4

unable to connect to adb.check the event log for a possible issue, verify that localhost entry is pointing to 127.0.0.1 or:: 1 for ipv4 or ipv6
Tried adb kill-server, restart, invalidate restart nothing works.
Same issue reported over here https://issuetracker.google.com/issues/130791561
Note: I have not added any file or anything in studio, it's fresh installed Studio after format a full system still issue is there.
Replace your platform-tools with this one and delete the other one.
https://dl.google.com/android/repository/platform-tools_r26.0.0-windows.zip
I was also facing this issue in android Studio 3.4 version, but now I have fixed it , if you are using windows then follow these steps:
Download Platform tools from here
https://dl.google.com/android/repository/platform-tools_r26.0.0-windows.zip
Extract downloaded zip file
Go To location "C:\Users\your_computer_user_name\AppData\Local\Android\Sdk" and Delete "Platform tools" folder
Copy and Paste, downloaded platform tool folder to above location
Now Go to your android studio and Rebuild your project Then run.
For Mac Users, follow these simple steps :
Just simply Navigate to Tools > SDK Manager> Android SDK>, then click on the Tab of SDK Tools, then look for Android SDK Platform-tools and update it.
Then the last step, Invalidate cache and restart your IDE, after that, then finally you restart your Mac. (Sometimes it's this step is unnecessary)
It will work out successfully.
Solution for Linux Users.
System info: Linux Mint Cinnamon 19.1 , Android Studio 3.4.1
Issue description: Problem with platform tools.
Solution: Remove the folder manually and update SDK tools through Android Studio.
Step 1: Go to your Android SDK installation folder. By default under your home directory. Choose platform-tools and simply delete. (/home//Android/SDK)
Step 2: Open Android Studio and go to SDK Tools. (File -> Settings -> Appearance & Behaviour -> System Settings -> Android SDK -> SDK Tools) By the moment you should be able to see Android SDK Platform Tools line unchecked.
Step 3: Put a check to install Platform Tools and press OK. Notice it'll relocate the folder to the directory where deleted.
Now that you re-installed the platform tools, restart the Android Studio and your deployment targets should show up.
If you don't install the platform tool back and ever try to build or run a project you'll get this IDE error. Just FYI :)
So that's all. Enjoy.
Happy coding
If you use Windows, you might have a corruption in api-ms-win-crt-runtime-l1-1-0.dll.
Try to update it - you can get the update from Microsoft's website.
You should check it - path/to/sdk/platform-tools and try to run adb.exe
When you update Sdk platform tools(which contains adb.exe) to release 28.0.2 and if you are using windows 8.1 then it needs few updates from windows.
As per SDK Platform tools release notes(https://developer.android.com/studio/releases/platform-tools):
Updated Windows requirements : The platform tools now depend on the Windows Universal C Runtime, which is usually installed by default via Windows Update. If you see errors mentioning missing DLLs, you may need to manually fetch and install the runtime package."
Windows update url: https://support.microsoft.com/en-ca/help/2999226/update-for-universal-c-runtime-in-windows
Prerequisite for Windows update url: https://www.microsoft.com/en-us/download/details.aspx?id=42327
Faced the exact same issue but after updating with prerequisite url first then the other url provided now it is working perfectly fine for me.
It worked for me by selecting -> Use libusb backend
This worked for me on Windows:
Goto cmd write %temp% hit enter -> delete all data from there.
Restart your Computer.
Open Android Studio now, it will work.
Clear all cache memory (related to Android Studio)
Restart ADB manually from Android Studio (first option)
Open Command prompt and got android sdk>platform-tools> adb kill-server
press enter
and again adb start-server
press enter
Restart ADB manually form Android Stidio (second option)
go to your (SDK store path) sdk>platform-tools>adb
press enter
ex. D drive > sdk>platform-tools>adb
Restart your system
Delete the platform-tools folder from the sdk and replacing with the same from your another pc. I am also facing this problem after updating to 3.4. If you face same problem please update to Android Studio 3.5 Canary Channel.
The reason is for ADB server problem. Simply re-run your adb.
(Go to your SDK folder then inside platform-tools folder you can see adb.exe. copy the path location and paste it in your computers system Environment variable. Set a new path there and paste the adb.exe file location there. hope it will solve )
If you are using Genymotion, there is an update that fix the problem.
Genymotion 3.0.2 (April 18th, 2019)
Corrections
We have fixed an
incompatibility with the adb tool bundled in the platform-tools 28.0.2
package of the Android SDK, which caused failures to start virtual
devices.
This new version of adb changed the behavior of the “adb connect
:” command by making the “port” part mandatory. This
broke Genymotion Desktop in a few places where it did not pass the
port. We have adjusted the way we call “adb connect” and also updated
the version we ship with the product to match the one in
platform-tools 28.0.2.
If non of the above answers worked for you (as same happend to me), down grade to the old version of Android Studio by following these steps:
Uninstall current Android Studio
Go to Android Studio Archive and download any older version
After installation, Open the project. You might see an error like this
This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer.
Now, open project gradle and update classpath tools.build version. I.e. in my case Android studio version is 3.2 and classpath 3.2.1
Hope it might save someone time.
I faced this issue last night, and I tried these methods to fix:
download older platform-tools and place it in the android sdk folder.(not work for me)
adb kill-server, adb start-server.(not work for me, adb had no response with these cmd)
kill the process that occupies port 5037.(for me, there is no other .exe run at this port)
reinstall platform-tools in Android Studio.(not work)
download ADB Kits and replace them in platform-tools folder.(work!!!)
It seems that my adb file has been modified or replaced by some programs. You can try these methods, and I hope some of them can work for you.
I had this issue only after a Genymotion update, on Mac.
What worked for me: Open Genymotion preferences, Select ADB, choose "Use custom Android SDK tools" and points to your Android SDK folder.
Actually the problem is not with the android studio version 3.4
Problem is with the android platform tools version which is latest one 29.
So install the previous version of the android platform tools version it will solve your problem. as above #Ved mentioned.
Ved link:
https://dl.google.com/android/repository/platform-tools_r26.0.0-windows.zip
EndTask adb.exe from Background processes (TaskManager) and Run Application again.
It works for me

<Flutter> emulator launched but not detected by android studio

I'm a beginner in Flutter and I've an emulator opened/powered on and android studio doesn't detect it.
Hence I can't run any program because "no device is running". I've tried installing 'Android emulator' in the SDK tools but android studio still cant detect it.
Android Studio device list shows "loading" and no devices connected. Thus, I opened emulator but I cannot run flutter on emulator on Android Studio. After 5 hours I found that the reason is the new Flutter version.
I solved with choose different version of Dart and Flutter!
You need to download 1.17.3 version. Quick download link: Dowloand Flutter SDK 1.17.3 Version
And switch Stable Channel & Dart: 2.8.4, this is important. Also, if you want, you can check all versions of Flutter SDK: Flutter Versions
On MacOS, just write terminal: flutter channel stable
Note: If this answer is not working for you, you can open android module of your flutter app in Android Studio. It can be helpful when you try to add Firebase skills.
I had same problem.
CMD: flutter devices
No devices detected.
CMD: device emulators
Device emulator-5554 is offline.
In Android virtual device manager, I cold boot emulator and it started working.
In a windows platform I did:
If you have ran flutter doctor and there is no issues and if you can run your flutter app in cmd or using VSCode:
Just try to open Android Studio or IntelliJ as administrator by right clicking on the icon. This may list down devices and solve your problem.
The reason may be you have cloned flutter repository or you don't have right permission in flutter installed directory.
Run flutter doctor command to check whats the problem.
In terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.
Check your flutter plugin whether it is up to date.
And read this flutter run: No connected devices , You may find the solution.
For me (on a Mac) I had the Android SDK installed in a custom location so I needed to set the ANDROID_HOME environment variable. In the terminal you can check what this value is with:
echo $ANDROID_HOME
I added the Android SDK to my .bash_profile (might be a different file if you are using Linux or Windows) for both ANDROID_HOME and PATH.
# already had these
export PATH="$PATH":"/opt/android-sdk/tools"
export PATH="$PATH":"/opt/flutter-sdk/bin"
# added this
export ANDROID_HOME="/opt/android-sdk"
Replace /opt/android-sdk with wherever yours is.
Then I updated the variables with
source .bash_profile
Testing with flutter doctor showed it was working.
flutter doctor
I restarted Android Studio and the emulator worked.
The last version of Flutter 1.17.5 (release the 2th, July) solved this issue for me.
Just flutter upgrade
run Flutter doctor to make sure you install everything.
run Flutter devices to see whether it is detected by flutter or not.
if you can find the your emulator there run flutter run -d <YOUR_EMULATOR_ID>
if you unable to find your emulator there may be you have to accept the android licenses . run flutter doctor --android-licenses to accept.
run flutter emulators to see list of emulators you have.
run flutter emulators --launch <emulator id> to launch
run Flutter devices to check whether emulator is detected by flutter or not.
run flutter run -d <YOUR_DEVICE_ID>
What worked for me is, updating Android Emulator.
Visit SDK Manager
Check whether any updates available for Android Emulator
If available, install the newest version
Hope this would be helpful!!!
I had this issue on Android Studio.
I had an emulator but it was not recognized even though the emulator was open.
I got around this by launching developer mode inside of the actual emulator by following the steps in this link: https://tweaklibrary.com/how-to-enable-developer-mode-on-android/#:~:text=How%20to%20Enable%20Developer%20Options%20On%20Android.%201,one%20of%20the%20most%20powerful%20...%20More%20items
After setting the emulator to developer mode, the emulator phone appeared as an option and when I ran the flutter hello world it appeared on the emulator.

Resources