Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build Android system.img and run it on emulator?

I have just compiled the AOSP and copied system.img to Android SDK directory on Windows. But the emulator can't boot the virtual device. Anyone knows why?

like image 634
Jack zhang Avatar asked Oct 27 '25 09:10

Jack zhang


1 Answers

Build ASOP and run on emulator

Build an AVD system image. This is the same process as building an Android device system image. For example, to build a x86 (Check this)

$ cd aosp-master
$source ./build/envsetup.sh
$ lunch sdk_phone_x86
$ make -j32

$ make -j32 sdk sdk_repo

$ cd ./out/host/linux-x86/sdk/sdk_phone_x86

You can see the build system images zip file as follows

$ ls

sdk-repo-linux-system-images-eng.[username].zip

extract the above zip

you can add to . ~/.bashrc or just type on terminal

$ export ANDROID_SDK=<Path_to_SDK>
$ export PATH=$ANDROID_SDK/emulator:$ANDROID_SDK/tools:$PATH

go to extracted folder

$ cd <extracted 
sdk-repo-linux-system-images-eng.[username]>

you can see image files in folder(./x86)

Create AVD by android studio. Go to Android Studio-> tools-> avd manager->create virtual device lets say we created Pixel_2_API_29

check available android virtual devices

$ emulator -list-avds

Pixel_2_API_29

then run build ASOP images on emulator

$ emulator -sysdir <Path_to_images> -avd <Created_AVD>

ex:

$emulator -sysdir <Patth_To_Extracted_Images/x86> -avd Pixel_2_API_29
like image 125
Hiranya Avatar answered Oct 29 '25 22:10

Hiranya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!