1

I downloaded and built the Android source based on the instructions mentioned here: but I can't get the emulator fired up. The following is my PATH and I had to manually add the emulator path:

$ echo $PATH
/usr/lib/jvm/java-6-sun/bin:/home/anil_ubuntu/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/s    bin:/usr/bin:/sbin:/bin:/usr/games:/home/anil_ubuntu/androidsrc/out/host/linux-x86/bin:/home/anil_ubuntu/androidsrc/prebuilt/linux-x86/toolchain/arm-linux-androideabi- 4.4.x/bin:/home/anil_ubuntu/androidsrc/development/emulator/qtools:/home/anil_ubuntu/android    src/prebuilt/linux-x86/toolchain/arm-linux-androideabi-   4.4.x/bin:/home/anil_ubuntu/androidsrc/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
anil_ubuntu@work:~/androidsrc$ 
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Anil Gorthy
  • 869
  • 3
  • 13
  • 30

5 Answers5

2

Easier way, I think, as below:

Just re-source the build env again, it's fast. There're two methods:

1) $ . build/envsetup.sh && lunch full-eng && emulator

This way Android will automatically search the system.img/userdata.img/ramdisk.img/kernel-qemu, etc. If you need specify the system.img/userdata.img, etc by yourself, using 2) method.

2) $ . build/envsetup.sh && lunch full-eng && 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 prebuilts/qemu-kernel/arm/kernel-qemu-armv7 -memory 512

frank
  • 539
  • 4
  • 3
1

You can add these to your .bashrc file

export ANDROID_PRODUCT_OUT=$ANDROID_SRC/out/target/product/generic

export ANDROID_BIN=$ANDROID_SRC/out/host/linux-x86/bin

PATH=$ANDROID_BIN:$PATH

Community
  • 1
  • 1
OneZero
  • 31
  • 2
1

Create a script file with the following code in the root folder of your android source project and run it after build. In my case it works perfectly but it is possible that you will need to change some parameters:

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
Yury
  • 20,618
  • 7
  • 58
  • 86
  • Thanks Yury! After I saw your note, I wonder if my build was even successful because I don't see the *.img files you mentioned above. Of course, as you rightly mentioned, I'll have to change some parameters to point to the correct directories. – Anil Gorthy Mar 21 '12 at 23:31
  • 1
    You can run emulator only in the case if you build sources for the emulator (meaning only if you execute command lunch full-eng or something like that). If you've built your images for a particular phone (like crespo or similar) you cannot run this images in the emulator. Thus, if you change the folders in my script this means that you've built the images for a real phone. You cannot run them in emulator. Good luck! – Yury Mar 22 '12 at 08:09
  • Yes, I used the lunch full-eng command. I rebuilt the source and now I see the ramdisk and userdata images. However, I am still missing the system image. I also verified that the 'ANDROID_PRODUCT_OUT' is also set from this other thread: [link](http://stackoverflow.com/questions/9022750/how-to-run-emulator-after-finishing-building-the-android-source-code) – Anil Gorthy Mar 23 '12 at 00:11
  • Sometimes it happens. I guess you should try to make a whole build once again. Run make clean, or simply delete out folder before that. Can you tell what's the version of Android you try to build? – Yury Mar 23 '12 at 07:17
  • I tried yet again but no luck. I tried both 4.0.1 r1 and 4.0.3 r1 and I am on Ubuntu 11.10; I'll try building on 10.04 as well and see if that works. – Anil Gorthy Mar 23 '12 at 23:35
  • @Yury Are you suggesting one has to build the source in a specific way to be able to use it in the emulator? That does not sound right. What would the lunch/make command look like? No mention of that in the official guide. And no "full" option in lunch. I am gonna try "lunch mini_emulator_x86_64-userdebug" though, as I was unable to run emulator with what I built after "lunch aosp_deb-userdebug" :( – Jaroslav Záruba Jan 07 '17 at 14:00
  • 1
    @JaroslavZáruba, actually, I just showed the example of the full command. You can always run the emulator (after you have built the sources) using the following commands: `source build/envsetup.sh`, `lunch aosp_arm-eng`, `emulator` – Yury Jan 08 '17 at 07:45
  • @Yury damn... that's how i do it and it does not work for me – Jaroslav Záruba Jan 08 '17 at 11:25
  • Most probably you do not have the sources built correctly. What the target did you use? What version of Android did you try to build? – Yury Jan 08 '17 at 12:58
0

After several rebuilds on Ubuntu 10.04/11.10 32-bit, I could finally compile the source (master) on 11.10 64-bit but I'd to make the following changes:

  1. build/core/combo/HOST_linux-x86.mk +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

  2. external/mesa3d/src/glsl/linker.cpp +'#include '

  3. external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive] -mutable counts_t & counts; +counts_t & counts;

  4. external/gtest/include/gtest/internal/gtest-param-util.h +#include

  5. external/llvm/llvm-host-build.mk: +"LOCAL_LDLIBS := -lpthread -ldl"

I read on various forums that Google is going to discontinue supporting 32-bit hosts so, if you are starting out to build the code, use 64-bit.

Anil Gorthy
  • 869
  • 3
  • 13
  • 30
0

Old post but the problem is that AOSP changed some stuff (including the location of prebuilt kernel), and when you do a source build/envsetup.sh this should fix it but it doesn't, anyway here's how you fix it:

emulator -kernel prebuilt/android-arm/kernel/kernel-qemu-armv7

I've found this kind of error just in version smaller or equal ICS. My emulator was looking for

prebuilts/qemu-kernel/arm/kernel-qemu-armv7

and in real the kernel it was in

prebuilt/android-arm/kernel/kernel-qemu-armv7

So, maybe this could useful for somebody who needs build a androd_4.0.1 version like me and got in troubles when try run it with the command emulator.

Pablo Silva
  • 47
  • 10