title: Android/AOSP: Fun & Qs about the "missing ranchu kernel"
body: <p>After I built Android  from AOSP source the <a href="http://source.android.com/source/building.html#emulate-an-android-device" rel="nofollow noreferrer">official guide</a> suggests that launching <code>emulator</code> is all one needs to do. Sadly that does not work for me...<br>
  (I am building for Nexus 7 "deb", Android Studio is not involved, not even present on this very machine.)</p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>Is my <code>ANDROID_SDK_ROOT</code> set properly?</strong> One would guess it should be <code>~/aosp/sdk</code>, but apparently the emulator expects <code>system-images</code> right under <code>${ANDROID_SDK_ROOT}/</code>. My <code>system-images</code> resides in <code>~/aosp/prebuilts/devtools</code> though.<br>
  When I change it to <code>~/aosp/prebuilts/devtools</code> it still isn't good enough:</p>
  
  <pre><code>...
  emulator: ERROR: ANDROID_SDK_ROOT is defined (~/aosp/prebuilts/devtools) but cannot find kernel file in ~/aosp/prebuilts/devtools/system-images/ sub directories
  </code></pre>
  
  <p>But there are actually several <code>kernel-ranchu</code> files in those subdirectories:</p>
  
  <pre><code>~/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
  </code></pre>
  
  <p><strong>Which one is the correct one and how do I deliver it to the emulator?</strong><br>
  I tried several <code>-kernel &lt;kernel&gt;</code> 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:</p>
  
  <pre><code>ERROR: resizing partition e2fsck failed with exit code 8
  </code></pre>
  
  <p>...strangely the process is not terminated, not sure how fatal the error is then.</p>