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
Related
I'd like to use only the command-line tools to create a new virtual Android device. I want to create a virtual Pixel.
I'm able to create a new AVD but unfortunately I can't figure out how to correctly set the skin and the correct device screen resolution.
This is what I've tried thus far:
C:\Users\*******\AppData\Local\Android\Sdk\tools>bin\avdmanager create avd -n MyPixel2 -k "system-images;android-25;google_apis;x86" --device 17
When I run that AVD via the emulator, I see a low-res device without any skin shown.
I am using Android SDK 25. And, unfortunately, it looks like https://developer.android.com/studio/command-line/avdmanager.html is out of date.
What you are describing is a limitation of the avdmanager command right now. What the emulator tool needs is a device skin that will tell the emulator what dimensions the phone screen needs to be. The avdmanager command is unable to take in a Device Skin Option at this time.
I recently created a helpful bash script that will create a device and then skin it using the device skins that are bundled with Android Studio.
Bash Repo
Take a look at the ReadME of the Repo for an in depth explanation of what the script does to make sure that the emulator will launch with the correct resolution.
But basically you are going to want to copy these lines into the config.ini of the device you created.
showDeviceFrame=yes
skin.dynamic=yes
skin.name={{skin_name}}
skin.path={{skin_path}}
hw.gpu.enabled=yes
hw.gpu.mode=auto
hw.ramSize=1536
And replace the {{skin_name}} with the name of the skin in your ANDROID_HOME/skins folder. As well as replace the {{skin_path}} with the path to the skin in your ANDROID_HOME/skins folder. The {{skin_path}} is just the path to the folder that contains the layout file.
If your SDK Directory doesn't have a skins folder than copy the skins folder located in my repository, to your SDK Directory.
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.
I am stuck flashing android to my nexus 7.
Steps to build image:
branch: refs/tags/android-4.4.2_r1
lunch : aosp_flo-userdebug
What i´ve done so far after building the image:
Like descibed in docs:
http://source.android.com/source/building-running.html
sudo fastboot flashall -w -p /home/stefan/bin/out/target/product/flo/
Gives me the following error:
could not load android-info.txt: No such file or directory.
So no luck with that, tried searching google but didnt find anything.
Downloaded an official rom 4.4.2 (KOT49H) from the nexus driver page:
https://developers.google.com/android/nexus/drivers
Deleted everything in the update package (zip) and putted my files in.
Then did sudo sh flash-all.sh
This method do flash the rom onto the device, but it also wont boot.
It hangs on the google splash screen.....
Is there anybody who can tell me how to properly flash my AOSP rom to device?
Your number 2 definitely will not work, and you shouldn't bother going down that route.
So the first issue you might have is you may be trying to build the wrong image, there are two Nexus 7s. Grouper is the designation for the first generation Nexus 7 and Flo is the designation of the 2013 Nexus 7, so make sure you have those right.
The second issue you may be having is the build may be failing. Are you sure that your make completed successfully? Your final message should say something similiar to
Install system fs image: out/target/blah/blah/blah/system.img
If you didn't see a line like that your build failed in which case you should diagnose that.
The third issue is you may be pointing at the wrong file. The line you are giving expects a full package, and you may not have created one. Try doing this instead:
sudo su
. build/envsetup.sh
lunch aosp_flo-userdebug
fastboot flashall -w
This will look for the generated files from the build automatically without you having to point at them, so long as you have selected the proper lunch option. Another issue you may be having is you may be confusing your shell with sudo, I am guessing you haven't bothered setting up the proper USB Permissions (see configuring USB access on the AOSP Build Guide. If you don't want to bother setting up USB permissions, then just initialize your environment as the super user after you have built when you need to flash (not before, or all your files will belong to root!)
I have aready build a emulator with new kernel from source.
And with the built file and source,the project folder is so huge.So,i want to part them off.
Here,i download the sdk tools.
So,i wonder which files does a emulator need at least?such like,system.img and what?
(What's more,i have also build a new kernel,and i want to run the emulator with this new kernel)
thx,in advance!
attached:
After a long time searching,i put the minimal files in a folder like:
:~/droidls
hardware-qemu.img system.img userdata-qemu.img
ramdisk.img userdata.img zImage
And then,i cd to this folder and put the android-sdk-linx/tools path into host os's PATH variable.
At last,I try to use the following command to start the emulator:
emulator -kernel zImage -ramdisk ramdisk.img -sysdir ~/droid -datadir ~/droid -data userdata-qemu.img -system system.img -initdata userdata.img
But it fails.
And with the built file and source,the project folder is so huge.
Please Describle it How the project folder got huge after built it.
So,i wonder which files does a emulator need at least?such
like,system.img and what?
Yes, its nice question. as Per the Official Documentation,
To use the emulator, you first must create one or more AVD
configurations. In each configuration, you specify an Android platform
to run in the emulator and the set of hardware options and emulator
skin you want to use. Then, when you launch the emulator, you specify
the AVD configuration that you want to load.
Each AVD functions as an independent device, with its own private
storage for user data, SD card, and so on. When you launch the
emulator with an AVD configuration, it automatically loads the user
data and SD card data from the AVD directory. By default, the emulator
stores the user data, SD card data, and cache in the AVD directory.
you can Go through the Here For More Description
What's more,i have also build a new kernel,and i want to run the
emulator with this new kernel
For query regarding Running with your New Kernal and running it with your emulator you can Go through Android Kernal Compile and Test with Android Emulator
Hope it Will Help
For running an application on device or emulator Android Package .apk file is needed. A .apk files contains .dex file(files converted to Dalvik byte code), resources files .arsc, Uncompiled resource and AndroidManifest.xml. For more detail see the developer guide document Building and Running.
I'm extending a custom Android kernel fork that originated as a 2.2
Froyo kernel. The build process itself is no problem; just type "make"
and its done. But I'm not sure of what I need to do to make the new
kernel known to other tools in the Android SDK; particularly
the emulator, adb, and the Eclipse debugger.
I've tried various things such as running the emulator with -system and
-userdata arguments on the command line, and these appear to work,
although I hit sporatic problems that leave me unsure. A common problem
I've seen is that sometimes apps "hang", displaying their UI but
refusing to go away even when the home or menu buttons are clicked. I've
tried turning off caching. But the real problem here is that I don't
have a good mental model of how kernel builds should be conveyed to
the SDK.
Should I be copying the build results (.img files) to
~/.android/ perhaps? Or to somewhere in the
SDK folder?
A working recipe would be nice, but better yet would be a
understanding of how the kernel build and SDK tools work together.
For example http://source.android.com/source/using-eclipse.html is
great for recipes but I still don't see how adb and emulator know
where to load .img files from.
When you've built android image the android webpage recommends to run it with emulator command. But you can run the built image in this way because android envsetup command has specified some paths before. For instance, to test my built image I run command:
out/host/linux-x86/bin/emulator -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata.img -kernel prebuilt/android-arm/kernel/kernel-qemu -sdcard sdcard.img -skindir sdk/emulator/skins -skin WVGA800 -scale 0.7 -memory 512 -partition-size 1024
So as you can see I specify all the images and all the paths explicitly. This is command to run image in emulator. Out folder is created during the build in your android source root folder.
P.S. Kernel usually refers to Linux kernel of Android. In your case, I think you have changed Android framework.
I've composed a full answer based on the invaluable clues Yury provided. The solution was to add these settings to my .bashrc. The tools (emulator, adb, ddms) in eclipse use these settings to pick up stuff from ANDROID_TARGET_OUT instead of getting them from the prebuilt copies inside the SDK. The CACHE stuff is the standard recommendation.
# Android SDK Build settings
export ANDROID_HOME="/Volumes/DroidImg/android-sdk-macosx"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export ANDROID_SDK_BASE="$ANDROID_HOME"
export ANDROID_SDK_HOME="$ANDROID_HOME"
export ANDROID_TARGET_OUT="/Volumes/DroidImg/Droid-Kernel/out/target/product/generic"
export USE_CCACHE=1
export CCACHE_DIR="/Volumes/DroidImg/CCACHE_DIR"
ulimit -S -n 1024
Finally, copy the .classpath provided with the SDK as documented on the wiki into the root of the kernel distribution, and "import existing files" into Eclipse. All Java components should now open and build properly in the package explorer. Very handy for exploring but don't forget you have to use ordinary make to build this stuff for real.
/Volumes/DroidImg is a case-preserving disk image I made for MAC-OS work; change this part of the path to suit.