1.问题描述:
以前编译android4.4的时候没啥问题,自从安装了eclipse后就编译不过,错误信息如下:
GenerateJNIHeader
jni_from_javap = JNIFromJavaP.CreateFromClass(input_file, options)
File "../../base/android/jni_generator/jni_generator.py", line 522, in CreateFromClass
jni_from_javap = JNIFromJavaP(stdout.split('\n'), options)
File "../../base/android/jni_generator/jni_generator.py", line 488, in __init__
signature=JniParams.ParseJavaPSignature(contents[lineno + 1]))]
File "../../base/android/jni_generator/jni_generator.py", line 147, in ParseJavaPSignature
return '"%s"' % signature_line[signature_line.index(prefix) + len(prefix):]
ValueError: substring not found
make: *** [out/target/product/smdk4x12/obj/GYP/shared_intermediates/ui/gl/jni/Surface_jni.h] Error 1
make: *** Waiting for unfinished jobs....
make: *** [out/target/product/smdk4x12/obj/GYP/shared_intermediates/android_webview/jni/InputStream_jni.h] Error 1
Traceback (most recent call last):
File "../../base/android/jni_generator/jni_generator.py", line 1103, in <module>
sys.exit(main(sys.argv))
File "../../base/android/jni_generator/jni_generator.py", line 1099, in main
GenerateJNIHeader(input_file, output_file, options)
File "../../base/android/jni_generator/jni_generator.py", line 1012, in GenerateJNIHeader
jni_from_javap = JNIFromJavaP.CreateFromClass(input_file, options)
File "../../base/android/jni_generator/jni_generator.py", line 522, in CreateFromClass
jni_from_javap = JNIFromJavaP(stdout.split('\n'), options)
File "../../base/android/jni_generator/jni_generator.py", line 488, in __init__
signature=JniParams.ParseJavaPSignature(contents[lineno + 1]))]
File "../../base/android/jni_generator/jni_generator.py", line 147, in ParseJavaPSignature
return '"%s"' % signature_line[signature_line.index(prefix) + len(prefix):]
ValueError: substring not found
make: *** [out/target/product/smdk4x12/obj/GYP/shared_intermediates/android_webview/jni/CancellationSignal_jni.h] Error 1
2.原因分析:
导致上述的错误应该是我在用eclipse的时候需要用jdk 7,而android4.4源码编译需要用jdk 6,所以才会出现莫名其妙的错误.
3.解决方法:
用一个命令就可以切换jdk版本,这个命令是:
sudo update-alternatives --config javap
如果只有一个jdk版本则需要添加javap
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.6.0_45/bin/javap 300
否则就需要选择jdk版本
root@ubuntu:/home/topeet/Android/iTop4412_KK4.4_git# sudo update-alternatives --config javap
There are 2 choices for the alternative javap (providing /usr/bin/javap).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/jdk1.8.0_74/bin/javap 300 auto mode
1 /usr/lib/jvm/jdk1.6.0_43/bin/javap 1 manual mode
2 /usr/lib/jvm/jdk1.8.0_74/bin/javap 300 manual mode
Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/lib/jvm/jdk1.6.0_43/bin/javap to provide /usr/bin/javap (javap) in manual mode.
root@ubuntu:/home/topeet/Android/iTop4412_KK4.4_git#
root@ubuntu:/home/topeet/Android/iTop4412_KK4.4_git#
root@ubuntu:/home/topeet/Android/iTop4412_KK4.4_git#
root@ubuntu:/home/topeet/Android/iTop4412_KK4.4_git# sudo update-alternatives --config javap
There are 2 choices for the alternative javap (providing /usr/bin/javap).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/jdk1.8.0_74/bin/javap 300 auto mode
* 1 /usr/lib/jvm/jdk1.6.0_43/bin/javap 1 manual mode
2 /usr/lib/jvm/jdk1.8.0_74/bin/javap 300 manual mode
Press enter to keep the current choice[*], or type selection number:
最后java -version的版本是改过来了,但是javac -version的版本没有改过来
root@maya-g450:/opt/FriendlyARM/android-4.2.2_r1# make -j4
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
TARGET_PRODUCT=full_tiny4412
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.16.0-77-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39
OUT_DIR=out
============================================
Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of javac.
Your version is: javac 1.8.0_74.
The correct version is: 1.6.
Please follow the machine setup instructions at
https://source.android.com/source/download.html
************************************************************
再次修改另一个文件:bashrc文件,把JAVA_HOME的目录改成java 1.6的就可以解决问题。
export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_43/
参考资料:http://www.linuxdiyf.com/linux/15546.html
http://blog.csdn.net/evahuangchen/article/details/48392539