Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AOSP x86_64 Emulator not visible in Android Studio

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.

like image 817
Umar Ata Avatar asked Feb 03 '20 08:02

Umar Ata


2 Answers

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

enter image description here

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

enter image description here

like image 152
Peter K Avatar answered Sep 22 '22 16:09

Peter K


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

like image 31
Umar Ata Avatar answered Sep 23 '22 16:09

Umar Ata