Add custom build to Android studio emulator

1,949 views
Skip to first unread message

Bastien Chanot

unread,
Aug 5, 2020, 10:50:45 AM8/5/20
to Android Building
Hi everyone ! I hope you are all good =)

I am talking to you today for asking you something. I don't find any answer on internet, so maybe some of you got it !

I just built a AOSP build, successfully, and i wish to add it to my android studio emulator. (on Ubuntu !)

I tried to follow the link https://source.android.com/setup/create/avd, i followed the process correctly, added the link ( like this file:///home/bchanot/Custom/repo-sys-img.xml)
But when i am trying to create an AVD through the Android Virtual Device software, i cannot find the image i specified in link.

Can someone help me ?

Thanks for all and sorry if i am not clear enough, ask me some questions !

Best regards,
Bastien.

Frank Yang

unread,
Aug 5, 2020, 12:05:07 PM8/5/20
to android-...@googlegroups.com
For creating an AVD off your platform build, currently there aren't good happy paths for it yet (we're working on it). A stopgap solution is to setup some default AVD in Studio (doesn't matter what the name is, let's call it 'someAvd' for now), note the path to the system image in $ANDROID_SDK_ROOT/system-images/..../x86 or x86_64, in ~/.android/avd/someAvd.avd/config.ini

Then, we can produce a img.zip in the Android build tree that contains a set of files that can replace the files in any $ANDROID_SDK_ROOT/system-images/..../x86, x86_64 folder:

echo $ANDROID_PRODUCT_OUT
MYPACKEDIMG=$1

mkdir -p $MYPACKEDIMG/img
rm -rf $MYPACKEDIMG/img/*
cd $MYPACKEDIMG/img
cp $ANDROID_PRODUCT_OUT/system-qemu.img system.img
cp $ANDROID_PRODUCT_OUT/vendor-qemu.img vendor.img
cp $ANDROID_PRODUCT_OUT/ramdisk-qemu.img ramdisk.img
if [ -f $ANDROID_PRODUCT_OUT/kernel-ranchu-64 ]; then
    cp $ANDROID_PRODUCT_OUT/kernel-ranchu-64 kernel-ranchu-64
else
    cp $ANDROID_PRODUCT_OUT/kernel-ranchu kernel-ranchu
fi;
cp -rf $ANDROID_PRODUCT_OUT/data .
cp -rf $ANDROID_PRODUCT_OUT/advancedFeatures.ini advancedFeatures.ini
cp -rf $ANDROID_PRODUCT_OUT/userdata.img .
cp -rf $ANDROID_PRODUCT_OUT/encryptionkey.img .
cp -rf $ANDROID_PRODUCT_OUT/system/build.prop .
cp -rf $ANDROID_PRODUCT_OUT/VerifiedBootParams.textproto .
cp -rf $ANDROID_PRODUCT_OUT/source.properties .

cd ..
zip -1rq img.zip img/*
ls -l img.zip

After replacing the files there, wiping AVD data and launching the AVD 'someAvd' from Studio should work.

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/1bea0c3e-2068-4f15-9701-fbd2cc5d8c41o%40googlegroups.com.

Frank Yang

unread,
Aug 5, 2020, 12:10:37 PM8/5/20
to android-...@googlegroups.com
There are also scripts in AAOS that might help but may need to be adapted to the general case:

utzcoz

unread,
Sep 12, 2020, 3:13:19 PM9/12/20
to Android Building
My code bases on AOSP 10. If I change the ramdisk part of above script with following content:

if [ -f $ANDROID_PRODUCT_OUT/ramdisk-qemu.img ]; then

cp $ANDROID_PRODUCT_OUT/ramdisk-qemu.img ramdisk.img

else

cp $ANDROID_PRODUCT_OUT/ramdisk.img ramdisk.img
fi;

it will work for me. Thanks @Lingfeng Yang.

Another thing, if there doesn't exist source.properties, we can copy it from current AVD instance,
or execute "make sdk" to generate it to out/host directory.

chanot....@gmail.com

unread,
Sep 28, 2020, 11:49:46 PM9/28/20
to Android Building
Hi again !
Link you gave me Lingfend Was usefull !

I just have a question, it seems to work only for build for 8.1 or after.
Do you know how to do it with 7.1 version ?

Because it missing a lot of file ^^" :
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/system-qemu.img': No such file or directory
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/vendor-qemu.img': No such file or directory
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/kernel-ranchu': No such file or directory
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/encryptionkey.img': No such file or directory
  • cp: cannot stat '/external/AOSP_7/device/generic/goldfish/data/etc/userdata.img': No such file or directory
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/VerifiedBootParams.textproto': No such file or directory
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/config.ini': No such file or directory
  • cp: cannot stat '/external/AOSP_7/out/target/product/generic_x86_64/advancedFeatures.ini': No such file or directory

Thanks for your answers !
Have a great day.
Best regards, Bastien
Reply all
Reply to author
Forward
0 new messages