Jack zhang
Jack zhang

Reputation: 41

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?

Upvotes: 4

Views: 8486

Answers (1)

Hiranya
Hiranya

Reputation: 114

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

Upvotes: 4

Related Questions