Expo/GenyMotion throws "ADB server didn't ACK" when running project - linux

I'm trying to set up a React Native project using GenyMotion and Expo on Ubuntu. However, when I click the 'Device' button in Expo to package the app onto the emulator, I get the following error in the Expo console:
I initially tried to use React Native through Android Studio, with the inbuilt Android emulator, so I thought the issue might that my computer hasmultiple ADB versions (when I ran $ adb --start-server from the terminal, it'd run the Android Studio binary, not the GenyMotion one). So I:
Removed everything Android Studio related that I could find, including the SDK at Android/Sdk/ and now $ adb --start-server
Ran $ sudo apt-get remove adb android-tools-adb
Set the filepath for the Android SDK in GenyMotion to my GenyMotion Android SDK. But I'm guessing is the same as the default setting, so I don't know if I needed to do this?
Removed all path variables related to Android Studio from my .bashrc file, including $ANDROID_HOME. (should I instead set $ANDROID_HOME to point to the GenyMotion Android SDK?
After doing the above, $ ps -aux | grep 5037 outputs the following:
even after quitting GenyMotion and Expo, so it looks like there is still a forked ADB daemon running. If I cd to my GenyMotion SDK and run $ ./adb kill-server (after quitting GM and Expo) that process doesn't show up in the output of ps anymore. However, interestingly, if I run $ ./adb start-server I get this:
But I don't know how to udpate the GenyMotion version of ADB. This also seems to indicate there are different ADB server and client programs. Is this correct? I have only ever interacted with the adb binary in the SDK folders.
UPDATE: I tried starting ADB from the terminal again, and cannot recreate the conflicting version error. The server starts perfectly now.
I was also having trouble with tunneling not working in Expo, so I've changed the host to localhost. It works, but I'm not sure exactly what the implications of this change are:
Obviously, I'm pretty new to Android development, and GenyMotion/Expo in particular. But I think I've been pretty thorough in my troubleshooting. What else can I try?

The solution, at least for me, was that I needed to add export PATH="/home/darik/projects/android/genymotion/tools:$PATH" to my .bashrc file. I'm guessing the reason the ADB server wasn't ACKing was that Expo couldn't find the ADB server in my path env variable.

The solution for me, was that I have multiple adb installed on the system.
And the adb version on my system is different from the adb version on the android sdk platform-tools.
I just add on PATH the right folder C:\\Ragnulf\AppData\Local\Android\Sdk\platform-tools

Ensure you have only one adb version added to your path, the one you need to use.
For me I removed the old ADB that I had installed, then I setup android sdk tools for Genymotion, read this article from their site Genymotion: Setup sdk tools with or without android studio
After installation of the tools:
For windows add to your environment path, the path to platform-tools
C:\<username>\path\to\android\sdk\platform-tools
For Linux or MacOS just add the following to your .bashrc or .zshrc or whaterver file is read by your terminal on initialization like:
export PATH="/path/to/android-sdk/platform-tools":$PATH
Platform tools is a subfolder within the Andorid SDK tools target installation folder, target folder looks like:
android-sdk
├── build-tools
├── emulator
├── licenses
├── patcher
├── platform-tools
└── tools

Related

I try to make android studio (emulator) work with vs-code but have an error "avdmanager is missing from the Android SDK"

This is my PATH
export ANDROID_SDK_ROOT=/mnt/sda1/DevTools/sdk/
export ANDROID_HOME=$ANDROID_SDK_ROOT
export PATH=${PATH}:/mnt/sda1/DevTools/sdk/platform-tools
I try many cases, but still this error!
Try :
flutter doctor --android-licenses
if something wrong, try to locate android sdk path.
flutter config --android-sdk {path}
Mine :
flutter config --android-sdk C:\Android\Sdk
This worked for me. If you have sdkmanager, avdmanager and emulator, and you have them in your PATH environmental variable, then
Download a system image:
sdkmanager "system-images;android-30;google_apis_playstore;x86_64"
(you can find available packages with sdkmanager --list --verbose)
Create a new virtual device with
avdmanager create avd --name MyAndroidDevice --package "system-images;android-30;google_apis_playstore;x86_64"
Start the emulator
emulator -avd MyAndroidDevice
Now restart VSCode and open your Flutter project. The new device should be at the bottom right corner or you should be able to choose it by clicking on "No device".
For me, I had to restart my VS Code for the installation of Android SDK be reflected upon it.
I know this is an old question but setting my $PATH variable in ~/.bashrc (I'm on Ubuntu 20.04) did not work for me.
I needed to setup Android Emulator for VScode, because I wanted to run my flutter app, which seems to be the same issue as OP had.
Instead of setting the $PATH directly you can actually use Flutter in the terminal to do it.
If you run "flutter config" in the terminal you get something like:
Configure Flutter settings.
To remove a setting, configure it to an empty string.
The Flutter tool anonymously reports feature usage statistics and basic crash reports to help
improve Flutter tools over time. See Google's privacy policy:
https://www.google.com/intl/en/policies/privacy/
....
Run "flutter help" to see global options.
Settings:
android-sdk: <my_path_to_android_tools>
Analytics reporting is currently enabled.
You can then see the $PATH that is currently set with flutter under:
Settings:
android-sdk: <my_path_to_android_tools>
Mine was incorrect so I changed it to the current one with the command:
flutter config --android-sdk <my_path_to_android_tools>
Afterwards I restarted VScode and when it was finished loading I could now press the "device" button in the right hand corner and then select emulator that I had already created. I used one of the above answers to install the emulator itself.
It took a while to launch the emulator the first time due to installing some dependencies but it did work!
I tried this and works:
from terminal run flutter config --enable-android. You will get Setting "enable-android" value to "true".
after that open android studio, set up virtual devices first if you haven't. Open Android Studio -> Configure -> AVD Manager -> Create Your Virtual Device
Go back to your VS Code, open command Palette (Ctrl+P or cmd+P, then type >), or from View -> Command palette... -> Flutter: Select Device -> choose your android device
I faced the same issue and solved it running flutter doctor from the terminal, in VS Code. In my case, I had the android sdk located in a custom location (D drive), the reason why it wasn't found automatically. The "doctor" told me to run flutter config --android-sdk <my-sdk-custom-location>. Running it and restarting the IDE made the trick. Hopefully this helps someone facing the same problem.

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:

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

How to run Ionic app on android-studio with capacitor on Ubuntu?

When I run the ionic capacitor run android command, to launch my application in Android Studio, I get the error saying:
Unable to launch Android Studio." You must configure "linuxAndroidStudioPath" in your capacitor.config.json to point to the location of studio.sh, using JavaScript-escaped paths:
example:
{
  "linuxAndroidStudioPath": "/usr/local/android-studio/bin/studio.sh"
}
but I configured the path my capacitor.config.json but the error persists.
Here's my capacitor.config.json file
First, run whereis android-studio in your terminal. This command will return the path of your android studio.
Mine is /snap/android-studio/current/android-studio/bin/studio.sh. I installed android-studio from the ubuntu software store. Maybe you installed it through a different source and in a different location.
Then add "linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh" in capacitor.config.json which is located in the root of your project.
Replace /snap/android-studio/current/android-studio/bin/studio.sh by your path. which is returned to you by whereis android-studio
"linuxAndroidStudioPath": "/snap/android-studio/current/android-studio/bin/studio.sh" is the path.
Add sudo when running the project sudo npx cap open android
in my case, android studio location was "/opt/android-studio/bin/studio.sh"
{
...
"linuxAndroidStudioPath": "/opt/android-studio/bin/studio.sh"
}
I use JetBrains Toolbox and macOS
to open the capacitor project with Android Studio with npx cap open android I had to export the Android Studio path as follow:
export CAPACITOR_ANDROID_STUDIO_PATH="/Users/myuser/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7199119/Android Studio.app"
Set environment variable--
Step1- Run: nano ~/.bashrc in terminal.
Step2- Add export CAPACITOR_ANDROID_STUDIO_PATH="path of android-studio/bin/studio.sh" in .bashrc file.
Step3- Run npx cap open android in terminal.
I have the same issue and I didn't manage to find out why it can't verify the path for android studio.
In order to use npx cap open android i had to open Android Studio before running the command.
Open your terminal and run gedit .bashrc.
Set the environment variable:
export CAPACITOR_ANDROID_STUDIO_PATH="path of android-studio/bin/studio.sh"
Save your file with Ctrl+s.
This will read your capacitor directly by running
Ionic cap open android
All of the answers here are on point, however I would like to add something small to note.
Its worth noting that Android Studio has different installation locations depending on the distribution you are using and also some installations are command-line based others are offline installations.
Some well known places are:
/usr/local
/usr/share
/opt
Lastly whereas the commands to search for android-studio may work in some instances where the default installation path was not changed. However the command
whereis android-studio
will not return anything in a case where the directory name is not the default i.e
/opt/android-studio-2021.2.1/android-studio/bin/studio.sh"
or
/usr/local/android-studio-2021.2.1/bin/studio.sh"
Here's how I solved this: In Ionic 6x, there's no capacitor.config.json. You'd have to set an environment variable of CAPACITOR_ANDROID_STUDIO_PATH globally. Do this by typing
export CAPACITOR_ANDROID_STUDIO_PATH=/path/to/android-studio/studio.sh
Worth noting that my Android Studio is found at /opt/android-studio/bin and not under /snap/...
Everything looks correct so the likely answer is that you have got the path wrong somehow.
Could you recheck it?
Also, are you running the latest versions of everything?

Android Emulator won't start from Android Studio on Windows 10

Recently (after install Android Studio 2.3.x, I'm now at 2.3.1) the emulator won't start in Android Studio.
I can run the emulator from the command line if it is in the SDK\tools directory.
If I run the emulator from a directory other than the SDK\tools directory I get an error like this:
[12236]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ..\emulator\lib64\qt\lib
Could not launch '..\emulator/qemu/windows-x86_64/qemu-system-i386.exe': No such file or directory
The tools and platform-tools directories are in my path. Android_home is set correctly. First I tried re-installing the emulator from the SDK manager in Android (now that the standalone SDK manager is gone I can't do it there). I manually downloaded the SDK and installed it overtop of the old SDK. I then tried putting it in a new directory and changing the ANDROID_HOME and updating my paths and changed the setting in Android Studio (and all the local.properties files). Next I completely uninstalled Android Studio and SDK, rebooted and reinstalled Android Studio. Still having the same problem.
I've tried the suggestions here in the question here: Emulator on Android Studio doesn't start after SDK tools update to 25.3.1 by copying various directories (first sym-links then copy directories as sym-links work differently on windows).
I've tried all the suggestions here: https://issuetracker.google.com/issues/37137213 as well.
I've re-installed HAXM, but I don't think it is an Emulator problem as it does work when I start it from a command prompt in the tools directory.
Any suggestions?
Details:
Windows 10 (Build 1703)
Android Studio 2.3.1
I've resolved the problem in this way:
in command line, from the folder containing avd images, I've run the emulator.exe against a virtual device image using the switch -gpu swiftshader.
To be precise, in my case, in command line, from the folder C:\<Users>\.android\avd I've typed
<android sdk folder>\emulator\emulator.exe #Nexus_4_Lollipop -gpu swiftshader
where Nexus_4_Lollipop is a name of the avd image.
Changing Graphics settings from "Automatic" to "Software - GLES 2.0" in Virtual Device Configuration worked for me. I think it's the same as "-gpu" command line option, but not all modes available: https://developer.android.com/studio/run/emulator-acceleration.html

Resources