Android – Failed to build Android kernel

Failed to build Android kernel… here is a solution to the problem.

Failed to build Android kernel

I’m trying to build an Android kernel for the emulator. But the build failed. I’m using android-5.1.1-r1.

The error message is as follows:

  mkdir -p /home/ying/WORKING_DIRECTORY/out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base; cd external/chromium_org/base; python .. /build/android//gcc_preprocess.py "--include-path=.." "--output=/home/ying/WORKING_DIRECTORY/out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base/ApplicationState.java"  "--template=android/java/src/org/chromium/base/ApplicationState.template" Traceback (most recent call last):

File ".. /build/android//gcc_preprocess.py", line 58, in sys.exit(main(sys.argv[1:]))

File ".. /build/android//gcc_preprocess.py", line 46, in main DoGcc(options)

File ".. /build/android//gcc_preprocess.py", line 29, in DoGcc build_utils. CheckOutput(gcc_cmd)

File "/home/ying/WORKING_DIRECTORY/external/chromium_org/build/android//util/build_utils.py", line 145, in CheckOutput stdout=subprocess. PIPE, stderr=subprocess. PIPE, cwd=cwd)

File "/usr/lib/python2.7/subprocess.py", line 710, in init errread, errwrite)

File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception

OSError: [Errno 2] No such file or directory make: * [out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base/ApplicationState.java] Error 1 make: * Waiting for unfinished jobs.... Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

make failed to build some targets (03:08 (mm:ss))

Did I miss something when setting up my environment?

I tried running the same make -j4 again. This time it took a lot longer, but in the end it still failed, and it was the same ApplicationState .java. Here are more news:

frameworks/base/packages/PrintSpooler/jni/com_android_printspooler_util_BitmapSerializeUtils.cpp:130:13: warning: unused parameter 'clazz' [-Wunused-parameter]
 static void writeBitmapPixels(JNIEnv* env, jclass clazz, jobject jbitmap, jint fd) {
             ^
action: ui_android_ui_android__ui_strings_grd_target_create_resources_zip (out/target/product/generic/obj//shared_intermediates/res.java/ui_strings_grd.zip)
timestamp: out/target/product/generic/obj//android_webview_jarjar_content_resources_intermediates/android_webview_jarjar_content_resources.stamp
timestamp: out/target/product/generic/obj//android_webview_jarjar_ui_resources_intermediates/android_webview_jarjar_ui_resources.stamp
mkdir -p /home/ying/WORKING_DIRECTORY/out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base; cd external/chromium_org/base; python .. /build/android//gcc_preprocess.py "--include-path=.." "--output=/home/ying/WORKING_DIRECTORY/out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base/ApplicationState.java"  "--template=android/java/src/org/chromium/base/ApplicationState.template"
action: android_webview_android_webview__android_webview_strings_grd_target_create_resources_zip (out/target/product/generic/obj//shared_intermediates/res.java/ android_webview_strings_grd.zip)
mkdir -p /home/ying/WORKING_DIRECTORY/out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base; cd external/chromium_org/base; python .. /build/android//gcc_preprocess.py "--include-path=.." "--output=/home/ying/WORKING_DIRECTORY/out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base/MemoryPressureLevelList.java"  "--template=android/java/src/org/chromium/base/MemoryPressureLevelList.template"
Traceback (most recent call last):
  File ".. /build/android//gcc_preprocess.py", line 58, in <module>
    sys.exit(main(sys.argv[1:]))
  File ".. /build/android//gcc_preprocess.py", line 46, in main
    DoGcc(options)
  File ".. /build/android//gcc_preprocess.py", line 29, in DoGcc
    build_utils. CheckOutput(gcc_cmd)
  File "/home/ying/WORKING_DIRECTORY/external/chromium_org/build/android//util/build_utils.py", line 145, in CheckOutput
    stdout=subprocess. PIPE, stderr=subprocess. PIPE, cwd=cwd)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
make: *** [out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base/MemoryPressureLevelList.java] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File ".. /build/android//gcc_preprocess.py", line 58, in <module>
    sys.exit(main(sys.argv[1:]))
  File ".. /build/android//gcc_preprocess.py", line 46, in main
    DoGcc(options)
  File ".. /build/android//gcc_preprocess.py", line 29, in DoGcc
    build_utils. CheckOutput(gcc_cmd)
  File "/home/ying/WORKING_DIRECTORY/external/chromium_org/build/android//util/build_utils.py", line 145, in CheckOutput
    stdout=subprocess. PIPE, stderr=subprocess. PIPE, cwd=cwd)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
make: *** [out/target/product/generic/obj//shared_intermediates/templates/org/chromium/base/ApplicationState.java] Error 1

#### make failed to build some targets (44:11 (mm:ss)) ####

Thanks

Solution

Finally it worked. It’s because there were some problems before this step:

$ sudo apt-get install bison g++-multilib git gperf libxml2-utils make zlib1g-dev:i386 zip

Judging by the message, it is possible that g++-multilib is not installed correctly. After ensuring that all packages in the command are installed correctly, the build succeeds.

Related Problems and Solutions