I am using AOSP emulator for testing my code. I downloaded the android10_release source code of AOSP in my pc. Then used the following commands
source build/envsetup.sh
set_stuff_for_environment
lunch aosp_x86_64-eng
make -j6
emulator
now after running these commands I am successfully able to run emulator in my pc OS of my pc is Ubuntu 18.04 I also installed many libraries for working with AOSP like jdk-8, python, curl, repo, git, and other stuff as per described in AOSP website
I am abe to see my emulator running in terminal by executing following commands
$ adb devices
List of devices attached emulator-5554 device
I am also able to install my apk in this emulator by executing following commands
$ adb install myapp.apk
and it gets installed and I can see it in emulator
Now coming to my question
Why this emulator not showing in Android studio in devices Even when I troubleshoot the adb connections in android studio it shows my emulator running but not showing in available devices.
Or connect to it via network adb connect localhost:5555
- port number is one higher than emulated device serial (in default case emulator-5554).
Then it is visible in Android studio and it works without issues.
solution that works for me (tried on two different machines):
$ cd aosp
$ repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r29
...
$ repo sync
...
$ . build/envsetup.sh
$ lunch sdk_phone_x86
$ m -j16
waiting for aosp to build
$ emulator &
$ adb devices
List of devices attached
emulator-5554 device
$ adb connect localhost:5555
connected to localhost:5555
$ adb devices
List of devices attached
emulator-5554 device
localhost:5555 device
start Android Studio (tested with 3.5.3 & 3.6.0)
In the devices list I see: "unknown Android SDK build for x86" with a little green dot next to it.
When I click on Run or Debug everything works
Finally after doing a lot of research I got to know that if I want to use Emulator of AOSP in Android Studio so I need to follow this guide Sharing AVD system images for others to use with Android Studio
Follow these instructions to share your AVD system images with others. They can use your AVD system images with Android Studio to develop and test apps.
Make additional sdk and sdk_repo packages:
$ make -j32 sdk sdk_repo
This creates two files under aosp-master/out/host/linux-x86/sdk/sdk_phone_x86:
sdk-repo-linux-system-images-eng.[username].zip
repo-sys-img.xml
Host the file sdk-repo-linux-system-images-eng.[username].zip somewhere accessible to your users, and get its URL to use as the AVD System Image URL.
Edit repo-sys-img.xml accordingly:
Update <sdk:url> to your AVD System Image URL.
See sdk-sys-img-03.xsd to learn about other updates to the file.
Host repo-sys-img.xml somewhere accessible to your users, and get its URL to use as the Custom Update Site URL.
To use a custom AVD image, do the following in the SDK Manager:
Add the Custom Update Site URL as an SDK Update Site.
This adds your custom AVD system image to the System Images page.
Create an AVD by downloading and selecting the custom AVD system image.
This link is helpful for reference
Create avd from AOSP to use in Android Studio and also share with others
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With