How to launch android emulator with my own .img partitions? - android

I compiled my own AOSP image and got this:
lz#vm:/mnt/android-dev-3/aosp/grapheneos-lz_experiments/out/target/product/generic_x86_64$ ls *.img
cache.img ramdisk.img system.img vendor_boot-debug.img
dtb.img ramdisk-qemu.img system-qemu.img vendor_boot.img
encryptionkey.img super_empty.img userdata.img vendor.img
ramdisk-debug.img super.img vbmeta.img vendor-qemu.img
I then compiled my own Android emulator.
I know I dont need to specify the .img myself, the AOSP prebuilt emulator just works, but I want to for other purposes.
So I did DIR_OUT = /mnt/android-dev-3/aosp/grapheneos-lz_experiments/out/target/product/generic_x86_64
./emulator -sysdir $DIR_OUT/system -datadir $DIR_OUT/data -kernel $DIR_OUT/kernel-ranchu -ramdisk $DIR_OUT/ramdisk.img -system $DIR_OUT/system.img -data $DIR_OUT/userdata.img -cache $DIR_OUT/cache.img -vendor $DIR_OUT/vendor.img
emulator: ERROR: No AVD specified. Use '#foo' or '-avd foo' to launch a virtual device named 'foo'
emulator: WARNING: userdata partition is resized from 550 M to 800 M
emulator: WARNING: encryption is off
Segmentation fault (core dumped)
You can see that I ignored the AVD error by commenting the return
if (!avdName && !avdArch && !androidOut && !forceEngineLaunch && !queryVersion) {
derror("No AVD specified. Use '#foo' or '-avd foo' to launch a virtual"
" device named 'foo'\n");
//return 1;
}
because without it I couldn t get anything to work. It could be segfaulting because of my quirk, but without it I dont see how to run with the .img myself.
Here s what the android emulator says about specifying my own .img files:
./emulator -help-disk-images
The emulator needs several key image files to run appropriately.
Their exact location depends on whether you're using the emulator
from the Android SDK, or not (more details below).
The minimal required image files are the following:
kernel-qemu the emulator-specific Linux kernel image
ramdisk.img the ramdisk image used to boot the system
system.img the *initial* system image
vendor.img the *initial* vendor image
userdata.img the *initial* data partition image
It will also use the following writable image files:
userdata-qemu.img the persistent data partition image
system-qemu.img an *optional* persistent system image
vendor-qemu.img an *optional* persistent vendor image
cache.img an *optional* cache partition image
sdcard.img an *optional* SD Card partition image
snapshots.img an *optional* state snapshots image
If you use a virtual device, its content directory should store
all writable images, and read-only ones will be found from the
corresponding platform/add-on directories. See -help-sdk-images
for more details.
If you are building from the Android build system, you should
have ANDROID_PRODUCT_OUT defined in your environment, and the
emulator shall be able to pick-up the right image files automatically.
See -help-build-images for more details.
If you're neither using the SDK or the Android build system, you
can still run the emulator by explicitely providing the paths to
*all* required disk images through a combination of the following
options: -sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache
-sdcard and -snapstorage.
The actual logic being that the emulator should be able to find all
images from the options you give it.
There s nothing saying how to overcome that error
UPDATE:
Segmentation fault is in this exact line:
https://android.googlesource.com/platform/external/qemu.git/+/refs/heads/aosp-emu-30-release/android-qemu2-glue/main.cpp#476
sysImagePath = std::string(
avdInfo_getSystemImagePath(m_avd)
?: avdInfo_getSystemInitImagePath(m_avd));
UPDATE:
I tried with
./emulator -sysdir $DIR_OUT/system -datadir $DIR_OUT/data -kernel /home/project/disk/aosp/grapheneos-lz_experiments/prebuilts/qemu-kernel/x86_64/5.4/kernel-qemu2 -ramdisk $DIR_OUT/ramdisk-qemu.img -system $DIR_OUT/system.img -data $DIR_OUT/userdata-qemu.img -cache $DIR_OUT/cache.img -vendor $DIR_OUT/vendor.img
(I added -qemu to some .img that had the qemu in the name)
But the problem persists the same

try this.
https://source.android.com/setup/create/avd
To build and run an AVD system image:
Download the Android source:
mkdir aosp-master; cd aosp-master
repo init -u
repo sync -j24
If you want to build other Android versions, you can find their branch names in the public Android repository. They map to Android Codenames, Tags, and Build Numbers.
Build an AVD system image. This is the same process as building an Android device system image. For example, to build a x86 32-bit AVD:
mkdir aosp-master; cd aosp-master
source ./build/envsetup.sh
lunch sdk_phone_x86
make -j32
If you prefer to build an x86 64-bit AVD, run lunch for the 64-bit target:
lunch sdk_phone_x86_64
Run the AVD system image in the Android Emulator:
emulator
See the Command-line startup options for more details about running the emulator. Figure 2 shows an example of the Android Emulator running an AVD.

Related

How to set a skin on a newly created avd using android-emulator 26.1.0.0

Reading through the documentation over developer.android.com regarding the emulator command line tool (now released separately since Android SDK 26.0.0), you can see the deprecated list of flags. One of them is -skin, but I cannot find any alternative to it.
I want to assign skins to my emulators created on a remote CI server with no display, but I want to ensure that the orientation and the display resolution is properly set, and from my testing I could only get that right when settings -skin flag to a given configuration.
Any tips of how to replace -skin flag or to achieve the same results without it?
Here's the version of the emulator I am running:
Android emulator version 26.1.0.0 (build_id 4010741)
Here's the command I use to create the avd:
avdmanager --verbose create avd --force \
--name "Nexus72012" \
--package "system-images;android-19;google_apis;x86" \
--sdcard 1000M \
--device 13
And this is how I start up the avd:
emulator #Nexus72012 -wipe-data -verbose -logcat '*:e *:w' -netfast -no-boot-anim -no-audio -no-window
Please note, I am limited to command line solutions, therefore please keep your answers targeted at that
I am on the same issue. But I got to set a galaxy skin not using the GUI. Here is the logic:
For the first time
Choose a directory to create an 'skins' folder in.
Now download the skin and unzip it into 'skins' folder.
Run emulator #Tester -skindir <dir> -skin <name>
That will run the created AVD named 'Tester' in the skin named <name> that will be search for inside <dir>.
use '-skin ' to specify an emulator skin, each skin corresponds to
the visual appearance of a given device, including buttons and keyboards,
and is stored as subdirectory of the skin root directory
(see '-help-skindir')
note that can also be 'x' (e.g. '320x480') to
specify an exact framebuffer size, without any visual ornaments.
use '-skindir ' to specify a directory that will be used to search
for emulator skins. each skin must be a subdirectory of . by default
the emulator will look in the 'skins' sub-directory of the system directory
If not the first time
Just download the skin (if not already) and unzip it into 'skins' folder.
Run emulator #Tester -skindir <dir> -skin <name>
You can use other options in additional to this. BTW, I got a galaxy skin from here.
also see.

Blank emulator after compililing Android 7.1.1 using Source code, how to get the emulator to work?

I have been trying to get the source code to compile from some time and finally got it compiled. However I am having issues with the emulator where it shows a pop up screen but is quite blank.
I am using Ubuntu Server Xenial and Android 7.1.1 for Nexus6P (but I dont own a Nexus6P so I need to run this on the emulator)
I have tried specifying all the directories such as (-sysdir,-sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache, -sdcard) although I know that these are supposed to be auto populated by the envsetup.sh file.
The command I used is this:
emulator -kernel ./prebuilts/qemu-kernel/arm64/kernel-qemu -ramdisk ./out/debug/target/product/angler/ramdisk.img -sysdir ./out/debug/target/product/angler/ -cache ./out/debug/target/product/angler/cache.img -system ./out/debug/target/product/angler/system.img -data ./out/debug/target/product/angler/userdata.img -memory 4096 -partition-size 4096 -sdcard sdcard.img -skindir ./sdk/emulator/skins/ -skin WVGA800
I changed the kernel to others such as for ARM/ARM64 but to no avail. All I see is a blank emulator and after changing it to ARM following error:
http://pastebin.com/A04NmNLn
I am at a loss as to why the emulator wont work. Also where is the "image" file with which we can install the Android on Genymotion-type external emulator.
Any help is appreciated!
In order to build AOSP to be run in emulator, there is no need to download any additional binaries. At the same time, emulator cannot run images build for real devices. Therefore, it is required to only download the sources of Android and execute the following commands within the directory with the downloaded sources:
source build/envsetup.sh
lunch aosp_arm-eng #or aosp_x86_64-eng, etc. for details see documentation
make -j4
After the sources are build in the same terminal run the emulator command and the emulator should appear.

which files does an emulator need to run at least?

I have aready build a emulator with new kernel from source.
And with the built file and source,the project folder is so huge.So,i want to part them off.
Here,i download the sdk tools.
So,i wonder which files does a emulator need at least?such like,system.img and what?
(What's more,i have also build a new kernel,and i want to run the emulator with this new kernel)
thx,in advance!
attached:
After a long time searching,i put the minimal files in a folder like:
:~/droidls
hardware-qemu.img system.img userdata-qemu.img
ramdisk.img userdata.img zImage
And then,i cd to this folder and put the android-sdk-linx/tools path into host os's PATH variable.
At last,I try to use the following command to start the emulator:
emulator -kernel zImage -ramdisk ramdisk.img -sysdir ~/droid -datadir ~/droid -data userdata-qemu.img -system system.img -initdata userdata.img
But it fails.
And with the built file and source,the project folder is so huge.
Please Describle it How the project folder got huge after built it.
So,i wonder which files does a emulator need at least?such
like,system.img and what?
Yes, its nice question. as Per the Official Documentation,
To use the emulator, you first must create one or more AVD
configurations. In each configuration, you specify an Android platform
to run in the emulator and the set of hardware options and emulator
skin you want to use. Then, when you launch the emulator, you specify
the AVD configuration that you want to load.
Each AVD functions as an independent device, with its own private
storage for user data, SD card, and so on. When you launch the
emulator with an AVD configuration, it automatically loads the user
data and SD card data from the AVD directory. By default, the emulator
stores the user data, SD card data, and cache in the AVD directory.
you can Go through the Here For More Description
What's more,i have also build a new kernel,and i want to run the
emulator with this new kernel
For query regarding Running with your New Kernal and running it with your emulator you can Go through Android Kernal Compile and Test with Android Emulator
Hope it Will Help
For running an application on device or emulator Android Package .apk file is needed. A .apk files contains .dex file(files converted to Dalvik byte code), resources files .arsc, Uncompiled resource and AndroidManifest.xml. For more detail see the developer guide document Building and Running.

Integrating custom Android kernel builds with SDK

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.

Android emulator cannot be started from windows console

I'm trying to run my android emulator on windows console but I get this error:
emulator: ERROR: Your system directory is missing the 'kernel-qemu' image file.
Please specify one with the '-kernel <filepath>' option
how can I fix this?. thanks for tour time.
----- UPDATE -----
I finally can fix this error. At fisrt, I planned to install android SDK offline rather than using SDK Manager. So I followed up this instruction and downloaded the components I need. Everything is correctly except that when I extract the platform using IZArc the file kernel-qemu which located in /platform/images/ is not extracted. But when I manually choose the file from IZArc and drag it to any folder it's extracted. Maybe this is about IZArc configuration but this error cost me for almost a week!
do you have your kernel image file under
< android >/tools/lib/images/
directory?
but i think your problem is your sintaxis to run the emulator
./emulator -kernel kernel-qemu -system
system.img -ramdisk ramdisk.img
-initdata userdata.img -partition-size 512

Categories

Resources