Unable to run emulator with Android built from source - missing kernel file

Hi

I followed the official guide on how to build Android from source. The build itself proceeds without a hiccup, but I am unable to run the result in emulator.
The guide suggests after a successful build I just need to launch the emulator. I guess the environmental variables set during the preparation process ought to guarantee the emulator knows where to look. Sadly I end up with complaints about missing kernel file.

Code:
emulator: ERROR: bad workspace: cannot find prebuilt ranchu kernel in: /home/jzaruba/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 (/home/jzaruba/aosp/sdk) but cannot find kernel file in /home/jzaruba/aosp/sdk/system-images/ sub directories

So apparently I need to set ANDROID_SDK_ROOT. I played with that a bit, tried to set it to all sorts of dark places...

Code:
... emulator: ERROR: ANDROID_SDK_ROOT is defined (~/aosp/development/ndk) but cannot find kernel file in ~/aosp/development/ndk/system-images/ sub directories

So now that damn thing is boldly lying to me! There are bunch of kernel-ranchu files in those subdirectories:

Code:
/home/jzaruba/aosp/development/ndk/system-images/android-23/google_apis/x86/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-23/google_apis/armeabi-v7a/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-23/google_apis/x86_64/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-23/android-tv/x86/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-23/default/x86/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-23/default/x86_64/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-25/android-wear/x86/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-25/android-wear/armeabi-v7a/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-25/google_apis/x86/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-25/google_apis/x86_64/kernel-ranchu /home/jzaruba/aosp/development/ndk/system-images/android-25/android-tv/x86/kernel-ranchu

My understanding is a different (non-production) kernel has to be used with the emulator. So I tried the -kernel option, pointed to all those above, one by one.
For the ones with "arm" in the path I get a dead emulator GUI (waited for tens of minutes, in case it was merely very slow)... The rest gave a fatal error causing the emulator to crash instantly:

Code:
qemu: fatal: Trying to execute code outside RAM or ROM at 0x00000004

How do I provide the proper kernel file please?

I googled and stackoverflowed like crazy. During last couple of days I started several times from the scratch, on a clean machine.
I tried Ubuntu 15 and 16, both as VM and also as a regular installation. I am building aosp_deb-userdebug (Nexus 7 [2013] w/ GSM), android-6.0.1_r55

echo $PATH:

Code:
/usr/lib/jvm/java-7-openjdk-amd64/bin:/home/jzaruba/aosp/out/host/linux-x86/bin:/home/jzaruba/aosp/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:/home/jzaruba/aosp/prebuilts/gcc/linux-x86/:/home/jzaruba/aosp/development/scripts:/home/jzaruba/aosp/prebuilts/devtools/tools:/home/jzaruba/aosp/external/selinux/prebuilts/bin:/home/jzaruba/aosp/prebuilts/android-emulator/linux-x86_64:/home/jzaruba/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

env | grep ANDROID:

Code:
ANDROID_DEV_SCRIPTS=/home/jzaruba/aosp/development/scripts:/home/jzaruba/aosp/prebuilts/devtools/tools:/home/jzaruba/aosp/external/selinux/prebuilts/bin ANDROID_PRE_BUILD_PATHS=/usr/lib/jvm/java-7-openjdk-amd64/bin: ANDROID_PRODUCT_OUT=/home/jzaruba/aosp/out/target/product/deb ANDROID_JAVA_TOOLCHAIN=/usr/lib/jvm/java-7-openjdk-amd64/bin ANDROID_BUILD_TOP=/home/jzaruba/aosp ANDROID_SDK_ROOT=/home/jzaruba/aosp/development/ndk ANDROID_BUILD_PATHS=/home/jzaruba/aosp/out/host/linux-x86/bin:/home/jzaruba/aosp/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin:/home/jzaruba/aosp/prebuilts/gcc/linux-x86/:/home/jzaruba/aosp/development/scripts:/home/jzaruba/aosp/prebuilts/devtools/tools:/home/jzaruba/aosp/external/selinux/prebuilts/bin:/home/jzaruba/aosp/prebuilts/android-emulator/linux-x86_64: ANDROID_TOOLCHAIN=/home/jzaruba/aosp/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin ANDROID_TOOLCHAIN_2ND_ARCH=/home/jzaruba/aosp/prebuilts/gcc/linux-x86/ ANDROID_EMULATOR_PREBUILTS=/home/jzaruba/aosp/prebuilts/android-emulator/linux-x86_64 ANDROID_HOST_OUT=/home/jzaruba/aosp/out/host/linux-x86 ANDROID_SET_JAVA_HOME=true

BTW aren't my img files somehow small? Compared to what I see in the system-images/ subdirectories the system.img is like 1/8 size...

Code:
-rw-rw-r-- 1 jzaruba jzaruba 26 led 5 18:19 android-info.txt -rw-r--r-- 1 jzaruba jzaruba 7,3M led 5 19:07 boot.img drwxrwxr-x 2 jzaruba jzaruba 4,0K led 5 19:03 cache/ -rw-r--r-- 1 jzaruba jzaruba 4,6M led 5 19:03 cache.img -rw-rw-r-- 1 jzaruba jzaruba 72K led 7 16:44 clean_steps.mk drwxrwxr-x 3 jzaruba jzaruba 4,0K led 5 19:07 data/ drwxrwxr-x 2 jzaruba jzaruba 4,0K led 5 18:53 fake_packages/ drwxrwxr-x 5 jzaruba jzaruba 4,0K led 5 18:43 gen/ -rw-rw-r-- 1 jzaruba jzaruba 1,5K led 7 17:00 hardware-qemu.ini -rw------- 1 jzaruba jzaruba 6 led 7 17:00 hardware-qemu.ini.lock -rw-rw-r-- 1 jzaruba jzaruba 74K led 7 16:59 installed-files.txt -rw-rw-r-- 1 jzaruba jzaruba 4,2M led 3 23:39 kernel -rw-rw-r-- 1 jzaruba jzaruba 6,4M led 5 18:42 kernel.bak drwxrwxr-x 13 jzaruba jzaruba 4,0K led 5 19:19 obj/ -rw-rw-r-- 1 jzaruba jzaruba 808 led 7 16:44 previous_build_config.mk -rw-rw-r-- 1 jzaruba jzaruba 899K led 5 19:07 ramdisk.img -rw-rw-r-- 1 jzaruba jzaruba 1,7M led 5 19:07 ramdisk-recovery.img drwxrwxr-x 3 jzaruba jzaruba 4,0K led 5 19:07 recovery/ -rw-rw-r-- 1 jzaruba jzaruba 67 led 5 19:07 recovery.id -rw-r--r-- 1 jzaruba jzaruba 8,0M led 5 19:07 recovery.img drwxrwxr-x 10 jzaruba jzaruba 4,0K led 5 19:07 root/ drwxrwxr-x 6 jzaruba jzaruba 4,0K led 5 19:07 symbols/ drwxrwxr-x 14 jzaruba jzaruba 4,0K led 5 19:10 system/ -rw-r--r-- 1 jzaruba jzaruba 369M led 7 17:00 system.img -rw-r--r-- 1 jzaruba jzaruba 135M led 5 19:11 userdata.img -rw------- 1 jzaruba jzaruba 135M led 5 20:12 userdata-qemu.img

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by rcummings
1 hour ago
Last post by alexandro.jenkins
52 minutes ago
Last post by frami.arlene
4 hours ago
Last post by homenick.beverly
2 hours ago
Last post by batz.rachelle
2 hours ago
Last post by pacocha.jake
18 minutes ago
Last post by destiney64
2 hours ago