I'm trying to run freshly built Android image on emulator (generic aosp_x86-eng target built from current master using Google sources). The emulator seems to be working fine, except it does not mount external SD card when run with -sdcard option. Emulator version is the one that comes from the git. Everything is executed on a headless server.
My complete list of steps:
repo init -u https://android.googlesource.com/platform/manifest
repo sync
. build/envsetup.sh
lunch aosp_x86-eng
make -j16
mksdcard 1G sd.img
emulator -no-window -no-skin -no-audio -sdcard sd.img &
adb shell mount | grep vfat
The virtual device appears to be correctly forwarded, as seen by the output of adb shell blkid:
/dev/block/vda1: LABEL="system" UUID="da594c53-9beb-f85c-85c5-cedf76546f7a" TYPE="ext4"
/dev/block/vdb: LABEL="cache" UUID="f73de97f-7017-ca5e-9b47-ca9c8f633e83" TYPE="ext4"
/dev/block/vde1: LABEL="vendor" UUID="6d16bab1-58d9-3c5d-8f14-f608f924affd" TYPE="ext4"
/dev/block/vdf: LABEL="SDCARD" UUID="1CEA-0B06" TYPE="vfat"
However, it is not mounted by vold. What could be the problem?
I also get the same result when I run emulator using Android 8 image downloaded via SDK manager. With Android 7, SD card works OK.
EDIT:
Solved the issue for emulator that comes with aosp_x86-eng build (see my own answer). On the emulator from Android SDK, the cause is probably different.
Turns out, in my case headless mode was the culprit. When I run emulator with -no-skin -no-window options, SD card is not mounted. If I remove these options (and enable X11 forwarding, since I work on a headless server), everything works correctly.
I still want to know why I can't use SD card in headless mode, but at least I was able to solve the problem for the required task.
Related
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
I need to include existing android emulator with the changes included in it (qcow2 files) in the docker image.
Sequencing:
1) Create an emulator through the Android Studio
2) Run it with the -writable-system option
emulator -avd xposed -writable-system
3) Make the necessary changes (Xposed installation, some xposed modules, data recording on the SD card and so on). All of these changes writing to qcow2 files (system.img.qcow2, sdcard.img.qcow2, etc.)
4) Stop the emulator
5) Archive it
cd /home/user/.android/avd && tar -cvzf xposed.tar.gz .
6) In the docker file:
ADD xposed.tar.gz /root/.android/avd
7) In xposed.ini change absolute path to the emulator instance
path=/root/.android/avd/xposed.avd
When try to run the emulator inside the docker - the qcow2 files with changes are recreated instead of used existing. :(
I get the same android-sdk tools and emulator versions, the same JDK and so on.
Also trying to change paths in harware-qemu.ini to the new one (/root/.android/avd/xposed/....) but no luck.
Some information about system and docker:
1) Android version 23 (6.0) x86 google_apis image
2) Run docker command:
sudo docker run -d -p 5900:5900 -p 5555:5555 --privileged -v /dev/kvm:/dev/kvm --name xposed xposed
3) Run android emulator command:
usr/local/android-sdk/emulator/emulator -avd xposed -noaudio -no-window -gpu off -verbose -qemu -usbdevice tablet -vnc :0
I really don`t know what to do. It is real, one time a have a luck, I get it and it was working great, but I lost this state and now nothing happens :(
By the way, in normal behavior I will get an error, like:
avd\system.img.qcow2,read-only: Could not open backing file: Could not open .....
But now no errors, it just override my files :(
I had the same problem when copying the emulator from the host to a docker container: the emulator inside docker would always start (in the best case) clean as after a factory reset, ignoring all my changes. This is how I solved the problem:
I started the emulator inside the docker container and I installed everything I needed (Xposed, custom apks etc.) while the emulator was running in docker.
After the emulator was setup the way I wanted, I turned if off and copied the /root/.android/avd/<emulator name> directory from the docker container to the host computer (by using docker cp command). This way I obtained a backup copy of the emulator with all the custom settings that can be used with docker.
I built a new docker image containing all the sdk stuff and tools needed to run the emulator and I added to the image the /root/.android/avd/<emulator name> directory previously saved. Now when I start a docker container from the new image I have a working emulator with all the settings I need.
Bonus tip: if you want to use the snapshot feature of the emulator, you have to commit the changes in the container to a new image (see docker commit command) and then use that new image, simply copying the avd directory will not work in this case and your snapshot will always be ignored.
I followed instructions here to build an open source android project(aosp-2.3.x).
After I finish building the project with:
. build/envsetup.sh
lunch aosp_arm-eng
make -j16
emulator
I can see a black screen emulator and two warning messages:
Could not automatically detect an ADB binary.
Some emulator functionality will not work until a custom path to ADB
is added in the extended settings page.
Running an x86 based Android Virtual Device (AVD) is 10x faster.
We strongly recommend creating a new AVD.
and in my terminal it shows:
emulator: WARNING: system partition size adjusted to match image file (2050 MB > 200 MB)
emulator: WARNING: encryption is off
when I run adb devices, it shows:
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
emulator-5554 offline
The emulator works in Anroid Studio, but not from the terminal when I tried to build the open source android project, is there any suggestions on how to fix this issue?
I got the same problem like this, try to uninstall android phone driver (check on remove driver and restart pc) then go on search "universal adb driver", download and setup it, it works for me, hope for you too!
PS C:\Users\Nguyen\AppData\Local\Android\sdk\platform-tools> adb devices
List of devices attached
xxxxxxxxxxxxxxxxxx device
I have been trying to get the source code to compile from some time and finally got it compiled. However I am having issues with the emulator where it shows a pop up screen but is quite blank.
I am using Ubuntu Server Xenial and Android 7.1.1 for Nexus6P (but I dont own a Nexus6P so I need to run this on the emulator)
I have tried specifying all the directories such as (-sysdir,-sysdir, -datadir, -kernel, -ramdisk, -system, -data, -cache, -sdcard) although I know that these are supposed to be auto populated by the envsetup.sh file.
The command I used is this:
emulator -kernel ./prebuilts/qemu-kernel/arm64/kernel-qemu -ramdisk ./out/debug/target/product/angler/ramdisk.img -sysdir ./out/debug/target/product/angler/ -cache ./out/debug/target/product/angler/cache.img -system ./out/debug/target/product/angler/system.img -data ./out/debug/target/product/angler/userdata.img -memory 4096 -partition-size 4096 -sdcard sdcard.img -skindir ./sdk/emulator/skins/ -skin WVGA800
I changed the kernel to others such as for ARM/ARM64 but to no avail. All I see is a blank emulator and after changing it to ARM following error:
http://pastebin.com/A04NmNLn
I am at a loss as to why the emulator wont work. Also where is the "image" file with which we can install the Android on Genymotion-type external emulator.
Any help is appreciated!
In order to build AOSP to be run in emulator, there is no need to download any additional binaries. At the same time, emulator cannot run images build for real devices. Therefore, it is required to only download the sources of Android and execute the following commands within the directory with the downloaded sources:
source build/envsetup.sh
lunch aosp_arm-eng #or aosp_x86_64-eng, etc. for details see documentation
make -j4
After the sources are build in the same terminal run the emulator command and the emulator should appear.
I have built the Android source for the emulator. I need to add sdcard to this emualtor.
Following are the commands, I use after the first full build:
source build/envsetup.sh
lunch 1
mmm packages/apps/MyApp/
adb sync
adb remount
However, I am unable to see the emulator in /mnt/sdcard path
What are the steps or commands, I need to use, in order to create an sdcard, when I use the emulator(with the commands above) built from Android source code.
I have been stuck with this issue for sometime. Any help is much appreciated.
after executing
$ make -j4
execute
$ mksdcard -l mySdCard 1024M mySdCardFile.img
and then
$ emulator -sdcard mySdCardFile.img
You have to go to the Android Virtual Device Manager, create your own or use an existing one and click the "Edit" button.
Then add some MB to your virtual SD Card.
Once started you can go to DDMS tab, then File Transfer tab and SDCard folder ;)