Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have built the Android source for the emulator. I read in the Android Source documentation that the path to 'emulator' is added autmatically during a successful build. However I have two questions about this:
If I open a new shell or close my existing shell, 'emulator' is no longer found. Surely I don't have to build each time I want to run the emulator?
If the emulator requires an AVD how do I create and manage these given there is no Android SDK on my machine?
Thanks,
Jack
SOLUTION to part 2.
I needed to create an environment variable called ANDROID_PRODUCT_OUT. From the the following command:
emulator -help-build-images
I read...
The emulator detects that you are working from the Android build
system by looking at the ANDROID_PRODUCT_OUT variable in your
environment.
If it is defined, it should point to the product-specific directory
that contains the generated system images.
I then did a search for 'system.ing' in my 'out' directory. since I am building for the emulator the image was in:
out/target/product/generic
I added the following line to my .bashrc file:
export ANDROID_PRODUCT_OUT=/home/jack.wootton/code/out/target/product/generic
I was then able to run the emulator from:
/home/jack.wootton/code/out/host/linux-x86/bin
SOLUTION to part 1.
I don't know about Android Virtual Devices, so this question still stands - however I did not need to provide one to run the emulator after doing a successful build and setting the ANDROID_PRODUCT_OUT environment variable.
Update to solutions
Apparently variables such as ANDROID_PRODUCT_OUT should be automatically created during a build and using the envSetup.sh script. I guess something has gone wrong with my environment setup for this not to happen.
You shared that:
Apparently variables such as ANDROID_PRODUCT_OUT should be automatically created during a build and using the envSetup.sh script. I guess something has gone wrong with my environment setup for this not to happen.
I ALSO ATTEMPTED to get this to work and LEARNED that:
lunch full-eng sets up all the appropriate env
to check it, simply run:
env | grep ANDROID
and you will see all the appropriate env variables setup.
These are local to the current shell only!
emulator then does what it should.
When I came back to the shell later, I simply ran lunch full-eng again to restore my environment.
I hope this helps others as well!
Just do the following:
source build/envsetup.sh or . build/envsetup.sh
setpaths
That does the trick. Make sure you run it from your source directory.
To check my built sources for emulator I've created the following script in the root folder of the project. I run it from another command line and it does not require to run all the time running . build/envsetup.sh and lunch full-eng commands. You can edit this script for your needs and if you need to run other device - simply change folder.
out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -sdcard sdcard.img -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 1024
You can add these to your .bashrc file
export ANDROID_PRODUCT_OUT=$ANDROID_SRC/out/target/product/generic
export ANDROID_BIN=$ANDROID_SRC/out/host/linux-x86/bin
PATH=$ANDROID_BIN:$PATH
In fact, the program "emulator" is just a wrapper for the real emulator-qemu, such as emulator-arm or emulator-x86. The "emulator" you invoked will collect the arguments you typed in and find the proper emulator-qemu to execute.
The problem you met is that you did not explicitly describe which image/avd you want to start. You can either using the argument "#avd YOUR-AVD_NAME" or "ANDROID_PRODUCT_OUT" environment variable to set the dir where your avd is placed. BTW, avd dir contains some files to describe how this device looks like.
". build/envsetup.sh" is the script that set the environment variables for the Android build process. So it is easy to understand why "ANDROID_PRODUCT_OUT" will be set at that time. Its default value should be "PATH/TO/ANDROID/out/target/product/generic".
PS: If you want to know more, you can refer to the source file: "PATH/TO/ANDROID/external/qemu/android/main-emulator.c". You can find the emulator main there.
Related
I am running android emulator in ubuntu-19.10 and I have attempted following solutions with no results,
Link-1
Link-2
Link-3
Error,
1:10 PM Emulator: pulseaudio: pa_context_connect() failed
1:10 PM Emulator: pulseaudio: Reason: Connection refused
1:10 PM Emulator: pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver
Some notes on solution I tried,
When trying Link-1 i don't see "Qemu-system" in settings. Also created many different versions of AVDs but does seem to work.
After trying Link-2 pulseaudio -D command errors out.
I have also tried Link-3 which looks like widely suggested solution in multiple blog posts. But still I find the same error on emulator startup. I would like to note that I am not smart enough understand this solution.
Thanks in advance for helping out.
Same problem in Ubuntu 20.04, with Android Studio installed from Ubuntu Software. Tried everything (paprefs, this), nothing worked. Uninstall Android Studio Snap and reinstall from tar package downloaded from Android Studio website, works perfect.
I was having a similar issue on Ubuntu 20.04 but I fixed it by uninstalling the store version of Android Studio and following the installation instructions on the Official Android Studio website here: https://developer.android.com/studio/install
If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
lib32z1 libbz2-1.0:i386
To install Android Studio on Linux, proceed as follows:
Unpack the .zip file you downloaded to an appropriate location for your applications, such as within /usr/local/ for your user profile, or /opt/ for shared users.
If you're using a 64-bit version of Linux, make sure you first install the required libraries for 64-bit machines.
To launch Android Studio, open a terminal, navigate to the android-studio/bin/ directory, and execute studio.sh.
Select whether you want to import previous Android Studio settings or not, then click OK.
The Android Studio Setup Wizard guides you through the rest of the setup, which includes downloading Android SDK components that are required for development.
I had the same issue, runing Intellij on Ubuntu 20.04. I solved it by adapting a solution from this link
I run this:
sudo ln -s /run/user/1000/pulse/native /run/user/1000/snap.intellij-idea-community/pulse
If you're using Android studio, just try to find "snap.intellij-idea-community" will be named differently, referring to your android studio installation.
On Ubuntu, is possible open the emulator with terminal and change the sound in System Preferences. Works with the instant version of Android Studio. It works with the snap version of Android Studio.
First is needed to add the emulator command to the PATH.
This can be done by editing .bashrc or .zshrc. Preferably these lines should be placed at the end of the file.
export ANDROID_SDK_PATH=$HOME/Android/Sdk
export ANDROID_NDK_PATH=$HOME/Android/Sdk/ndk
export PATH="$PATH:$HOME/Android/Sdk/platform-tools"
export PATH="$PATH:$HOME/Android/Sdk/emulator"
The PATH variable needs to be reloaded. This can be done manually, as shown below, or simply by opening another terminal:
source ~/.bashrc
# OR
source ~/.zshrc
Another way is to add adb and android-sdk-platform-tools-common packages to have the emulator command available. Package names may vary depending on the Ubuntu version.
After that, the emulator command can be used to list available emulators:
emulator -list-avds
Example of output:
Pixel_4_API_30
Pixel_C_API_30
Then can be opened one of the available emulators:
emulator #Pixel_4_API_30
Finally, the emulator probably will appear at the System Preferences:
If this is a Snap it's got strict requirements as far as i/o; that said, if the requirements are similar to those of running Androidx86 using Vbox on Debian (I realize Qemu is a different environment, however, this may be of use for both Jbaba as well as future reference. Step one: make sure that you belong to the group Qemu (or the equivalent for Ubuntu/Snap?). Step two: make sure you belong to the group pulseaudio. Step three: make sure that Qemu is explicitly permitted to access whatever your audio output device is and that it's the device that pulseaudio is configured to output to. There should be a fairly intuitive way of seeing this using Qemu (it's been awhile, so I am not able to tell you where to find it). As for pulseaudio; its GUI will show you.
I got crazy while trying to solve this issue but finally, it was solved. I figured out that we have to enable multiple simultaneous audio outputs in order to hear both sounds the emulator and the OS.
The solution is by installing paprefs small app as the following.
1- Install it:
$ sudo apt install paprefs
2- Open it:
$ paprefs
3- Go to the last tab Simultaneous Output and click on the only option there in order to enable the Simultaneous Output.
4- Restart it:
$ pulseaudio -k
5- If it fails then you have to restart the daemon
$ pulseaudio -D
6- Almost finished, go to the system settings and navigate to Sounds options and change the output sounds to the newly added one as below.
OS : Ubuntu 20.04.
Android studio (snap).
I tried all the methods, none worked for me.
By installing these libs, the sound works now.
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
as Gigi mentionned before
I have downloaded and compiled Android source code per instructions on Android source website (http://source.android.com/source/building.html)
I chose
$ lunch full-eng
an emulator engineering build and everything has compiled just fine.
Then it says to launch the image inside an emulator just type:
The emulator is added to your path automatically by the build process. To run the emulator, type
$ emulator
Well, not sure it is added to the path. Typing emulator does not do anything.
However if I go to
out/host/darwin-x86/bin/emulator
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.
If you are an Android SDK user, please use '#<name>' or '-avd <name>'
to start a given virtual device (see -help-avd for details).
So I am confused ... at this point do I have to create an AVD ?
How do I create an AVD for this image exactly ?
Has anyone done this on MAC can they supply me with some instructions ?
Thanks
I'm not sure if there is any difference on osx, but it is a common error on Linux. After you build the whole AOSP, the building process will add the <AndroidBase>/out/host/<host-arch>/bin/emulator into the PATH, but after you restart your computer or open another session, emulator will no longer be in the path.
To fix the "You did not specify a virtual device name, and the system
directory could not be found" error, you can explicitly set ANDROID_PRODUCT_OUT to point to your disk image directory. In general, the disk image directory would be <AndroidBase>/out/target/product/generic. So
$export ANDROID_PRODUCT_OUT=<ANDROID BASEDIR>/out/target/product/generic/
would help.
Actually, you can run
. build/envsetup.sh
setpaths
It will do a similar work for you.
I build with aosp_x86_64-eng and have verified that the following will launch the emulator in a new terminal window:
cd /[your AOSP WORKING_DIRECTORY]
source build/envsetup.sh
lunch aosp_x86_64-eng
cd $ANDROID_PRODUCT_OUT
emulator
I'm using Terminal-IDE as my development environment. (Google code site here.)
I'm running Terminal-IDE v 2.02 - the very latest. My Android versions are:
Android 4.0.3
Software version 2.14.531.3 71ORD
(the rest aren't likely pertinent, but more on request)
I'm in a suitable development directory with a simple enough c source code file ready and run 'make'.
I have never yet gotten any compilation to work successfully. Most likely, there's a version mis-match with regard to what executable is available versus what the software is looking for.
Here's the command and error message:
terminal-gcc -c -Wall -I/data/data/com.spartacusrex.spartacuside/files/local/include tester.c -o tester.o
/data/data/com.spartacusrex.spartacuside/files/system/bin/terminal-gcc[43]: arm-eabi-gcc: not found
make: *** [tester.o] Error 127
Snafu, of course. I'm not at all sure how to find out what the right compiler file name(s) should be because, on this non-rooted phone, I don't have permissions to hunt through the PATH and find the actual executables.
It may also be that PATH is set wrong. All input appreciated.
...I'm not sure what's supposed to happen, but I found in the Terminal-IDE directory tree the file:
$IDESYSTEM/android-gcc-4.4.0.tar.gz
I also found that terminal-gcc is a bash script. Looking inside it seemed to say that a gcc tree should exist in "$HOME", which is the installation directory. So, I unzipped, then un-tarred the file identified above and put the resulting directory tree as a top-level subdirectory.
Well well, what do you know? Success.
I went a little further and created soft links to the actual compiler in ~/bin for both gcc and just cc, and suddenly all my previously created "Makefile" scripts used in other projects I wanted to move over started working perfectly.
Apparently, even though I thought I'd done it right, I overlooked running this script:
./system/bin/install_gcc
It extracts the tar, like I did, but does not create the links you may need.
Hey, if you're glad I got here before you, give it a thumbs up!
A credit goes to #Richard T for his enthusiasm regarding Terminal IDE. The answer is intended to enumerate the steps needed for running a C code.
To run a C code
Run Terminal IDE and extract the gcc package by executing
install_gcc
Create a directory for your projects within the Terminal IDE directory tree. Then in the directory create a source .c file with some code (filename.c here). Compile it
terminal-gcc -c filename.c
Create the executable file
terminal-gcc filename.o -o filename.out
Run the output file
./filename.out
If you'd like to use the PC (laptop) keyboard you can telnet Terminal IDE.
To Telnet Terminal IDE
From Terminal IDE start the telnetd deamon by executing
telnetd
Connect the Android device to the PC (laptop) and type
adb forward tcp:[port] tcp:8080
telnet 127.0.0.1 [port]
P.S. Telnet's default port is 23.
I'm extending a custom Android kernel fork that originated as a 2.2
Froyo kernel. The build process itself is no problem; just type "make"
and its done. But I'm not sure of what I need to do to make the new
kernel known to other tools in the Android SDK; particularly
the emulator, adb, and the Eclipse debugger.
I've tried various things such as running the emulator with -system and
-userdata arguments on the command line, and these appear to work,
although I hit sporatic problems that leave me unsure. A common problem
I've seen is that sometimes apps "hang", displaying their UI but
refusing to go away even when the home or menu buttons are clicked. I've
tried turning off caching. But the real problem here is that I don't
have a good mental model of how kernel builds should be conveyed to
the SDK.
Should I be copying the build results (.img files) to
~/.android/ perhaps? Or to somewhere in the
SDK folder?
A working recipe would be nice, but better yet would be a
understanding of how the kernel build and SDK tools work together.
For example http://source.android.com/source/using-eclipse.html is
great for recipes but I still don't see how adb and emulator know
where to load .img files from.
When you've built android image the android webpage recommends to run it with emulator command. But you can run the built image in this way because android envsetup command has specified some paths before. For instance, to test my built image I run command:
out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -sdcard sdcard.img -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 1024
So as you can see I specify all the images and all the paths explicitly. This is command to run image in emulator. Out folder is created during the build in your android source root folder.
P.S. Kernel usually refers to Linux kernel of Android. In your case, I think you have changed Android framework.
I've composed a full answer based on the invaluable clues Yury provided. The solution was to add these settings to my .bashrc. The tools (emulator, adb, ddms) in eclipse use these settings to pick up stuff from ANDROID_TARGET_OUT instead of getting them from the prebuilt copies inside the SDK. The CACHE stuff is the standard recommendation.
# Android SDK Build settings
export ANDROID_HOME="/Volumes/DroidImg/android-sdk-macosx"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export ANDROID_SDK_BASE="$ANDROID_HOME"
export ANDROID_SDK_HOME="$ANDROID_HOME"
export ANDROID_TARGET_OUT="/Volumes/DroidImg/Droid-Kernel/out/target/product/generic"
export USE_CCACHE=1
export CCACHE_DIR="/Volumes/DroidImg/CCACHE_DIR"
ulimit -S -n 1024
Finally, copy the .classpath provided with the SDK as documented on the wiki into the root of the kernel distribution, and "import existing files" into Eclipse. All Java components should now open and build properly in the package explorer. Very handy for exploring but don't forget you have to use ordinary make to build this stuff for real.
/Volumes/DroidImg is a case-preserving disk image I made for MAC-OS work; change this part of the path to suit.
After I built the source code of android, I ran the following command and got the error.
#fastboot -w flashall
error: could not load android-info.txt
I had successfully built the source code for nexus one (build 5), and I found that there is a android-info.txt file in the directory out/target/passion/.
Also, I am sure that the phone is connected. When I run "fastboot devices", it shows the device.
Anybody know the reason?
Old thread so sorry for reactivating it, but it's still one of the top hits and it's unanswered.
My fix was to ensure I had the ANDROID_PRODUCT_OUT environment variable, and that it was pointing to
/home/{usr name}/{build directory}/out/target/product/{taget}
Again, sorry for resurrecting a dead post.
As $fastboot flashall -w
flash the Rom on connected device it needs to know which Run/Device/Product you want to flash as there might be many products available in out/target/product directory,
And so product is obtained by ANDROID_PRODUCT_OUT variable which should point to any product i.e.
/home/{usr name}/{build directory}/out/target/product/{taget}
And to set the ANDROID_PRODUCT_OUT we just need to do:
source build/envsetup.sh
lunch
and choose your product in lunch menu, so that fastboot flashall -w would know which product you wanna flash.
It depends on how the flash all script is organized. Try flashing into the partition directly.
Eg: fastboot flash system system.img
I observed this issue when trying to fastboot update an OTA package.
Eg: fastboot update xyz.zip.
Currect way to update via fastboot is
fastboot update updateImagename.img
Call lunch to set the environment variables needed.
For example,
'lunch aosp_flo-eng' can be called to make sure the environment is in order for the Nexus 7 [2013] tablet.