Could not launch emulator in Android Studio - android

I tried to launch application in emulator in android Studio in ubuntu 14.04 and it shows the following errors.
Error shown while gradle build is in process:
/home/next/NTE/MachineSetup/android-sdk-linux/tools/emulator -netdelay
none -netspeed full -avd Nexus_5X_API_24
Could not launch
'/home/next/NTE/MachineSetup/android-sdk-linux/tools/qemu/linux-x86/qemu-system-x86_64':
No such file or directory
Error appear after gradle build completed:
12/02 16:47:57: Launching app Error while waiting for device: The
emulator process for AVD Nexus_5X_API_24 was killed.
I have attached screenshots for your reference.

The first error's reason is below:
There are two emulators: one in $SDK/tools, another one in $SDK/emulator.
The one in $SDK/tools cannot start.
Please place $SDK/emulator before $SDK/tools in your $PATH variable, it should fix the problem.

I'm using Android Studio 2.3: edit file : .profile
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/emulator
before
export PATH=${PATH}:${ANDROID_HOME}/tools
Like:

Not sure if this will help for you but I was seeing this error trying to run emulator in the console. I changes the ANDROID_SDK to point to the bin folder in my .bash_profile and that corrected the issue
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK=$ANDROID_HOME/lib

I try with this code in .bashrc now it's working:
export ANDROID_HOME=/home/AccountName/Android/Sdk
export PATH=${PATH}:${ANDROID_HOME}/emulator

1: add $SDK/emulator in your $PATH variable
2: remove $SDK/tools in your $PATH variable
3: adb kill-server
4: adb start-server
5: Start the emulator from the command line
Example:
emulator #Pixel_XL_API_23

It may be Android Emulator is not installed.
To add it to the Android Studio installation, go to Tools->Android->SDK Manager, select the SDK Tools tab, then ensure that Android Emulator is selected.

So I looked around to find some similair posts that encountered what you did, for the 1st error I found this that might fix the issue:
qemu-system
for the second one:
I saw multiple people that had this issue (source not super relevant). Some recommended updating your android studio or the SDK. Seeing as this might intervene with the 1st error I recommend just doing the 1st step and then check again.

Also, this happened for me when I had the system image installed — but not the emulator itself.

I faced same issue today. These are steps i did and now working fine. I am using arch-linux os.
process will be same on .bashrc too.
export PATH=${ANDROID_HOME}/emulator:${PATH}
export PATH=${ANDROID_HOME}/tools/bin:${PATH}
export PATH=${ANDROID_HOME}/platform-tools:${PATH}
I faced error due to exporting path to tools directory instead of bin directory in tools.
export PATH=${ANDROID_HOME}/tools:${PATH}
This solution is for android-sdk.

Try copy 'lib' folder from your Android sdk location /Android/Sdk/tools/lib64/qt/lib to ../Android/Sdk/tools/lib/qt/lib

Related

MAC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

I'm having the problem that I can't start an emulator in android studio.
I get these errors:
20:06 Emulator: PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
20:06 Emulator: Process finished with exit code 1
I read that I need to change something in vim ~/.bash_profile. I tried it but it didn't work. It currently looks like this:
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# added by Anaconda3 5.2.0 installer
export PATH="/Users/jonas/anaconda3/bin:$PATH"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home
export ANDROID_HOME=/usr/local/share/android-sdk
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
Please note that I don't have any idea what vim ~/.bash_profile does or what I have changed in it lol.
I also tried uninstalling the emulators and android studio itself but it didn't work. Can I maybe clean something to complete the whole android sdk?
btw I'm on Mac.
Any ideas what I could do?
I saw all the posts about updating your bash, but it seemed you should be able to set that from within Android Studio.
Preferences > System Settings > Android SDK
One of the items in this pane lists the file system path to the android SDK, typically in your home directory (user folder). There may also be \ a list of SDK versions supported, such as Android Q, Android Pie (version 9), etc.
The first time I added an emulator I tried oreo and got the PANIC error.
I created a new one, and used Q, which according to the list i described was installed (the others, including oreo were not)
When I launched the emulator, I got my 'Hello World' example app.
So I think that if you are creating an emulator, it needs to be in sync with what you have installed.
you need to define your ANDROID_SDK_ROOT and ANDROID_AVD_HOME.
open your terminal and type open -a TextEdit ~/.bash_profile
Add this 2 line and change {your user} by your current
user :
export ANDROID_SDK_ROOT=/Users/{your user}/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/ryadahitdep/.android/avd
3. CMD + S to save your changes

Error: Could not find or load main class com.android.uiautomator.UiAutomatorViewer

I am trying to run Android's UiAutomatorViewer on ubuntu system but when i run this command uiautomatorviewer it gives this error: Error: Could not find or load main class com.android.uiautomator.UiAutomatorViewer I have set path to .bashrc file:
export ANDROID_HOME=/home/rahulsharma/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
When i run other program of tools folder like sdk manager, that executes successfully.
Does anyone know where i am doing mistake?
Could not find the reason that why i am getting this error but found solution. To start UiAutomatorViewer:
Open terminal
In terminal go to tools folder inside android sdk
run ./uiautomatorviwer command.
Ui Automator Viwer is running now.
May be helpful for someone.
In my case, the uiautomatorviewer is located inside <android-sdk>/tools/bin
Open terminal, go to <android-sdk>/tools/bin
run ./uiautomatorviewer
Hope this will be helpful.
Pretty similar way in recent version of Windows, while e.g. %ANDROID_HOME% is declared in PATH as %userprofile%\AppData\Local\Android\Sdk then simply run:
cd %ANDROID_HOME%/tools/bin
uiautomatorviewer.bat

ERROR: 32-bit Linux Android emulator binaries are DEPRECATED

I installed the latest version of the ADT Bundle 32 bit on my ubuntu 14.04 32 bit. I created an AVD, but it doesn't launch. When I press the start button it shows this message:
Starting emulator for AVD 'NexusOne'
ERROR: 32-bit Linux Android emulator binaries are DEPRECATED, to use them
you will have to do at least one of the following:
- Use the '-force-32bit' option when invoking 'emulator'.
- Set ANDROID_EMULATOR_FORCE_32BIT to 'true' in your environment.
Either one will allow you to use the 32-bit binaries, but please be
aware that these will disappear in a future Android SDK release.
Consider moving to a 64-bit Linux system before that happens.
I tried to fix it by setting export ANDROID_EMULATOR_FORCE_32BIT=true to gedit .profile file and to gedit .bashrc file. Nothing changed.
Thank you for trying to help me!
i have one great solution.
you can start it with eclipse or netbeans.
try :
In Eclipse, click your Android project folder and then select Run > Run Configurations...
In the left panel of the Run Configurations dialog, select your Android project run configuration or create a new configuration.
Click the Target tab.
In the Additional Emulator Command Line Options field, enter:
-force-32bit
Run your Android project using this run configuration.
in netbeans you :
1. wher you choose debuger chose Customize...
in Emulator options write
-force-32bit
click ok. and run application
I solve this problem with the following:
export ANDROID_EMULATOR_FORCE_32BIT=true
Then I start the emulator from the command line. It works!
Hope it's helpful to you.
I did the following
go to the run configuration >target tab> scroll down to the last> Additional emulator command line options>-force-32bit
solution to this problem is given here
Open terminal in ubuntu, and then type gedit .profile
paste this text: export ANDROID_EMULATOR_FORCE_32BIT=true
refresh source i.e. in terminal type source .profile
When no effect, finishing that by restart your device (laptop,pc)
For Android Studio:
Run > Edit Configurations > Android > Android Application > app > Emulator tab
Enable the checkbox next to Additional command line options:
Enter -force-32bit
go to the run configuration >target tab> scroll down to the last> Additional emulator command line options>-force-32bit
I had same problem and now I solved,I have Ubuntu 15.10 And my solution was:
Open terminal
Locate path directory Android-studio at terminal
I wrote export ANDROID_EMULATOR_FORCE_32BIT=true, keyboard key enter
And execute the ./studio.sh locate in folder bin of Android-studio
ON LINUX MINT
Go to terminal
type gedit .profile
paste the below line at end of the page
export ANDROID_EMULATOR_FORCE_32BIT=true
type source .profile in terminal or restart system
ON UBUNTU
Go to terminal
type gedit .bashrc
paste the below line at end of that file
export ANDROID_EMULATOR_FORCE_32BIT=true
type source ~/.bashrc in terminal or restart system
create a shell script :
#!/bin/bash
#
# set export ANDROID_EMULATOR_FORCE_32BIT=true
export ANDROID_EMULATOR_FORCE_32BIT=true
/opt/adt-bundle-linux-x86-20140702/eclipse/eclipse
change the shell script executable and run it to active eclipse
"/opt/adt-bundle-linux-x86-20140702/eclipse/eclipse" is the path of eclipse

android Failed to start emulator:Cannot run program

I have installed android SDK and android eclipse plugin successfully on Ubuntu.
Every thing was working fine until I removed Ubuntu and installed Linux Mint.
I installed the SDK again and used the same eclipse copy I was using on Ubuntu but now all the android applications contain errors and I can not start the emulator.
When starting the emulator this message appears
Starting emulator for AVD 'test' Failed to start emulator: Cannot run program "/home/anas/android//tools/emulator": error=2, No such file or directory
While the android SDK is installed in the specified path and the file (emulator) is exists in the same path.
Also all my applications contains the same error R can not be resolved to a variable
What is the problem here?
Installed on Ubuntu successfully.
but not running avd
If you're running a 64-bit system, you need to install ia32-libs
sudo apt-get install ia32-libs
R can not be resolved to a variable
This can be due to following Reason
class is not the part of that package add proper package
not properly defined in manifest file class path define it properly
clear and run the avd it will work
If cmd from fist comment doesn't work like in my case (64bit Crunchbang) then you may also try with :
sudo aptitude install ia32-libs lib32ncurses5 lib32stdc++6
I solved it doing a backup of the "emulator" and creating a symbolic link to the correct emulator:
mv emulator emulator_bup
ln -s emulator64-arm emulator
I used the command-line tool android (android avd), and used Tools->Manage SDK to install 64 bit emulators. I then mv'ed emulator to emulator.old, and emulator64-arm to emulator. Now the AVD starts up.
You do not need install packages any more!
In directory tools, there are many types of emulator, while my computer works with emulator64-arm! My system is Linux Mint 16 amd64! Good luck!
./emulator64-arm #yxphone -sdcard yxsd -scale 0.8
Like you have written the specified path and the files are exists in the same path, but i suggest to check that one more time.
and like you are getting R cannot be resolved to a variable, do not worry:
Reasons:
Check Package name in Manifest File
If you are already getting something like this: import com.version.bajrang.january.R;
so first of all try to change package name here, or secondly just delete this line and
clean your program
If you are not getting something like: import com.version.bajrang.january.R;
then add import packagename.R;
I believe that you will get your answer.....
It looks like your SDK path in eclipse has a mistake:
Cannot run program "/home/anas/android//tools/emulator"
That double "//" may be the problem. Check in Eclipse: Window -> Preferences -> Android. There should be a field there pointing the SDK Location. Edit it.
Check your path : /home/anas/android/ to see if it really is where you put your SDK . If not repeat these steps to have it
The missing R resource message is a compile error right? Then in this case your emulator should not be the problem. However, if your SDK path is incorrect like I suspect, then .. you can expect this compile error along with any other android libraries import
This is sorted by running this on Ubuntu.
sudo cp ~/Android/Sdk/platform-tools/adb /usr/bin/adb
Refer this: Can't connect to emulator through ADB genymotion

How do i run the Android command line tools?

I'm still pretty new to Android and programming in general, and I can't seem to get the command line tools packaged with the Android SDK to work. I'm running Mac OSX and each time I try to run layoutopt, for example, the terminal returns, *-bash: cmd: command not found
*
Also, is it okay to have my SDK located in the Developer directory and my android project in some unrelated directory when using these tools?
If you want you can put the path in your ~/.bash_profile so you can call it from anywhere:
export ANDROID_HOME=/Users/<username>/path/to/sdk/tools
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
You may want to include also the platform-tools into your ~./bash_profile
### Android dev tools
export ANDROID_HOME="/Users/myusername/DEV/tools/adt-bundle-mac-x86_64/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
You will need to start a new terminal session or run
source ~/.bash_profile
to loads the values immediately without having to open a new terminal session.
The current (2016-08-17) answer to this question is:
~/Library/Android/sdk
So my bash_profile contains:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools
I figured it out. I needed to go to the /tools directory in the SDK folder and type in:
./layoutopt <directorypath>
Problem is your command line tool is not seeing required programs from /path/to/sdk/tools.
One solution as user NKijak mentioned is to add those tools to your Home path and the other is to run command line from location where your sdk tools are stored. Here is a tutorial how to do just that http://hathaway.cc/2008/06/how-to-edit-your-path-environment-variables-on-mac-os-x/
Other way is, when opening command line just change your current dir to /path/to/sdk/tools and then run the tools. In windows you can just shift+right click in file explorer and pick open command windows here I am not sure is there equivalent on MacOS but there are some extensions you can install to add this option. Also total commander in windows has command line where you can start command line from current location there are similar programs on mac like Midnight Commander that have same option.
Here is a good description:
To connect to the console of any running emulator instance at any time, use this command:
telnet localhost <console-port>

Categories

Resources