Nexus 5 AVD and Lollipop AOSP - android

I am able to compile AOSP + binaries and flash my Nexus 5 device. I then realized that it would probably be more practical to make my changes and run these builds on the emulator first to sanity check what I'm doing (I use my Nexus 5 as my main phone).
I've tried running the emulator by typing "emulator" after the build. I get the following error:
ko:Invalid cache partition image type: yaffs2 (expected ext4)
I created a Nexus 5 AVD in Android studio and confirmed that ANDROID_PRODUCT_OUT is pointing to /out/target/product/hammerhead, then I tried the following from the /out/target/product/hammerhead directory:
emulator -avd Nexus_5_API_21 -kernel ~/android-5.0.1_r1/prebuilts/qemu-kernel/x86/kernel-qemu -system ./system.img -ramdisk ./ramdisk.img -data ./userdata-qemu.img
The emulator appears to start up, but I see nothing.
Another piece of information that might help is that when I run the command "android list" I see the following:
Available Android targets:
Available Android Virtual Devices:
The following Android Virtual Devices could not be loaded:
Name: Nexus_5_API_21
Path: ~/.android/avd/Nexus_5_API_21.avd
Error: Unknown target 'android-21' in /home/julio/.android/avd/Nexus_5_API_21.ini
It doesn't seem to like the target android-21, and there doesn't seem to be any targets defined at all.
Anyway, does anyone know how to get this working? I want to avoid having to constantly flash my phone.
Thanks

Building for emulator and real devices are different things. In order to build AOSP for an emulator, you do not need to download any additional binaries. You should only select appropriate targets in lunch command. You can choose among the following targets:
aosp_arm
aosp_x86
aosp_x86_64
etc.
These targets build images to run on different processors architectures (arm, x86, x86-64, etc.).
You can also select different variants (user, userdebug, eng). The details of these variants of builds are explained here.

Related

Blank emulator after compililing Android 7.1.1 using Source code, how to get the emulator to work?

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.

Android/AOSP: Fun & Qs about the "missing ranchu kernel"

After I built Android from AOSP source the official guide suggests that launching emulator is all one needs to do. Sadly that does not work for me...
(I am building for Nexus 7 "deb", Android Studio is not involved, not even present on this very machine.)
emulator: ERROR: bad workspace: cannot find prebuilt ranchu kernel in: ~/aosp/prebuilts/qemu-kernel/arm/ranchu/kernel-qemu
emulator: ERROR: This AVD's configuration is missing a kernel file! Please ensure the file "kernel-ranchu" is in the same location as your system image.
emulator: ERROR: ANDROID_SDK_ROOT is defined (~/aosp/sdk) but cannot find kernel file in ~/aosp/sdk/system-images/ sub directories
Is my ANDROID_SDK_ROOT set properly? One would guess it should be ~/aosp/sdk, but apparently the emulator expects system-images right under ${ANDROID_SDK_ROOT}/. My system-images resides in ~/aosp/prebuilts/devtools though.
When I change it to ~/aosp/prebuilts/devtools it still isn't good enough:
...
emulator: ERROR: ANDROID_SDK_ROOT is defined (~/aosp/prebuilts/devtools) but cannot find kernel file in ~/aosp/prebuilts/devtools/system-images/ sub directories
But there are actually several kernel-ranchu files in those subdirectories:
~/aosp/prebuilts/devtools/system-images/android-23/android-tv/x86/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-23/default/x86/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-23/default/x86_64/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-23/google_apis/armeabi-v7a/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-23/google_apis/x86/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-23/google_apis/x86_64/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-25/android-tv/x86/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-25/android-wear/armeabi-v7a/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-25/android-wear/x86/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-25/google_apis/x86/kernel-ranchu
~/aosp/prebuilts/devtools/system-images/android-25/google_apis/x86_64/kernel-ranchu
Which one is the correct one and how do I deliver it to the emulator?
I tried several -kernel <kernel> but either I got a fatal memory error (for the x86_64-based ones) or I get an emulator with black screen and a popup saying that emulator based based on x86 would be much faster (with the google_apis/armeabi-v7a.) I waited tens of minutes for the last one, nothing happens, still the black screen, not even "android" logo. Maybe because in the middle of the output there is following message:
ERROR: resizing partition e2fsck failed with exit code 8
...strangely the process is not terminated, not sure how fatal the error is then.
Select your CPU/ABI to Google APIs Intel Atom (x86_64) when create the simulator AVD
The issue was that only small subset of targets is intended to run in the emulator. Those with specific device in their name ("deb") are not blessed.
After days of struggling with aosp_deb-userdebug and -eng I tried full-eng and that one works as charm.

Android AVD for Jelly Bean and Google APIs --

I tried to get an Android AVD working for Jelly Bean (API-16) and Google APIs (I included both in the platform definition). When running the AVD I would get the following error.
$ emulator -avd Nexus_7_API_16_With_Google_APIs
emulator: ERROR: This
AVD's configuration is missing a kernel file!! emulator: ERROR:
ANDROID_SDK_ROOT is defined (C:\data\applications\Android\Sdk) but
cannot find kernel file in
C:\data\applications\Android\Sdk\system-images\ sub directories
I've read through all the similar instances I could find on Stackoverflow and other sites, but none seemed pertinent to my situation.
Unlike most configuration files, the ones used for Jelly Bean and Google API appear to be located in
add-ons rather than in system-image. E.g.:
$ cd $ANDROID_SDK_HOME/.android/avd/Nexus_7_API_16_With_Google_APIs.avd/config.ini
$ grep image config.ini
image.sysdir.1=add-ons\addon-google_apis-google-16\images\armeabi-v7a
In fact, "system-image" appears to be hardcoded into the emulator (although it is possible there is a path around that -- see Cannot run emulator in Android Studio).
This looks very much like a bug to me.
Advice???
Thanks,
Barry

Run custom ROM on Android Emulator

I downloaded a third-party ROM, and I want to run it on the emulator first before flash it into the phone. Here is the contents of cm-11-20140911-NIGHTLY-p3110.zip:
1. boot.img
2. file_contexts
3. META-INF/
4. recovery/
5. system/
I unpacked boot.img using the script unpack-bootimg.pl and get boot.img-kernel, and boot.img-ramdisk.cpio.gz. Then I repacked the system using the make_ext4fs and got system.img.
I created an AVD and execute:
emulator -system ~/cm11/system_new.img -ramdisk ~/cm11/boot.img-ramdisk.cpio.gz -kernel ~/cm11/boot.img-kernel -avd and442
but all I got is nothing, the emulator screen is just black. There is no log message from adb -s emulator-5554.
Now I am confused:
can the third-party ROM be tested by the emulator?
Am I doing the right way?
Yeah, why not.
We can flash a third-party ROM on Android AVD. But first you must know the following things:
1. The Android Emulator is itself a device, like your Moto G or Xperia
2. Every ROM is device-specific (supports a device-specific Kernel)
(on many sites/blogs you got information like you have to replace system.img file from .android\avd\avdname.avd, but it is technically incorrect, because you also require ramdisk.img.)
To do this, you need to create your own AOSP repository by downloading the particular repository and have to build your own .img files)
You can do it in two ways:
replace files system.img and ramdisk.img from location .android\avd\avdname.avd
Build your own AOSP. Before... make in "lunch" select target as: Emulator (like: genericX86), i.e., generate all emulator specific .img files
I have tried many things. It's a bit critical, but interesting. The following links may help you:
To run your cooked ROM on Emulator (link down. Try this, from archive.org).
To Create AOSP Project

Eclipse Android SDK ERROR: unknown virtual device name

So, the issue i correctly installed eclipse,android sdk,ndk, coocs2d-x 2.1.4. I can build cocos2d-x android project, import it to eclipse, etc. Everything seems fine, but not really. The problem is that i can't launch my virtual machine to emulate andoid OS. I created avd, it works fine with simple android projects, but when i use it to run cocos2d-x project as android application it does nothing. No output at all. I found this guide and followed it. But i faced a problem. 1st of all, when i follow this step:
Now start the Android for x86 Intel Emulator using the following command:
$ <SDK directory>/tools/emulator-x86 -avd Your_AVD_Name -qemu -m 2047 -enable-kvm
i have an error message:
gloomist-CN tools # ./emulator-x86 #myavd -qemu -m 2047 -enable-kvm
emulator: ERROR: unknown virtual device name: 'myavd'
emulator: could not find virtual device named 'myavd'
But it is in sdk as a valid android virtual device. And the next one. In that tutorial that i pasted link to above, the last step is:
Run the emulator with the correct library path and options
Make sure to
Set the library path to the directory containing the Open GL library for the emulator (LD_LIBRARY_PATH=...)
Run the x86 version of the emulator (run /tools/emulator-x86)
Enable GPU use (Use the option "-gpu on")
Also, you need to specify the name of the Android Virtual Device to use (Use the option "-avd ")
On OS X the command line looks like this
LD_LIBRARY_PATH=~/bin/android-sdk/tools/lib ~/bin/android-sdk/tools/emulator-x86 -verbose -avd android17x86 -gpu on
i don't really know what author meant by all this. Could anyone explain me the way to do it in linux?
So basically, the main problem is: how to run a cocos2d-x project on AVD in eclipse on lixnux? That's it.
I use Linux version 3.2.0-23-generic (buildd#palmer) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu4) ) #36-Ubuntu SMP Tue Apr 10 20:41:14 UTC 2012 (Ubuntu 3.2.0-23.36-generic 3.2.14).
Can anyone help me to figure out how can i accurately launch my cocos2d-x project on AVD using eclipse?
Are you sure 'myavd' is a valid avd?
Try to run this command to get a list of AVD's you have created in your system:
# <SDK directory>/tools/android list avd
And re-run emulator-x86 passing a valid avd.
I also suggest you follow the step by step guide about how to configure your android enviroment which comes with cocos2d-x dist. You can find it in: /samples/Cpp/TestCpp/proj.android/README.md
Hope this helps
I was able to fix this error on Ubuntu 18.04 by running:
sudo chmod 777 /dev/kvm
Its not exactly high security, but it gets the job done.

Categories

Resources