Android平台编译期间出错:“#ifndef指令末尾的额外令牌[-Werror]”

时间:2015-04-14 15:17:49

标签: android

这是Android源代码编译。

在几个晚上重复“repo sync”之后,然后“make -j4”我将在编译的每个不同日期得到以下错误。 (我的Java是Oracle JDK的6u45版本,主机是Linux Ubuntu 64位LTS 14.04)。但是做同样的事情(从“repo sync”编译)不会导致另一个Ubuntu 14.04 LTS(64位)出错,我甚至可以执行“模拟器”来启动另一台机器上的asop_arm-eng模拟器映像。第一台机器肯定有问题。

谷歌搜索没有发现任何类似的错误,有人请帮忙吗?

target thumb C++: content_content_common_gyp <= external/chromium_org/content/common/android/common_jni_registrar.cc
target thumb C++: content_content_common_gyp <= external/chromium_org/content/common/android/device_telephony_info.cc
target thumb C++: content_content_common_gyp <= external/chromium_org/content/common/android/hash_set.cc
target thumb C++: content_content_common_gyp <= external/chromium_org/content/common/android/surface_texture_peer.cc
target thumb C++: content_content_common_gyp <= external/chromium_org/content/common/android/trace_event_binding.cc
In file included from external/chromium_org/content/common/android/hash_set.cc:5:0:
out/target/product/generic/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:10:26: error: extra tokens at end of #ifndef directive [-Werror]
out/target/product/generic/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:11:26: error: missing whitespace after the macro name [-Werror]
In file included from external/chromium_org/content/common/android/hash_set.cc:5:0:
out/target/product/generic/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:24:20: error: expected initializer before '<' token
out/target/product/generic/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:26:17: error: expected initializer before '<' token
out/target/product/generic/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:29:22: error: expected '{' before '<' token
out/target/product/generic/obj/GYP/shared_intermediates/content/jni/HashSet_jni.h:29:22: error: expected unqualified-id before '<' token
external/chromium_org/content/common/android/hash_set.cc:30:1: error: expected '}' at end of input
cc1plus: all warnings being treated as errors
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/content_content_common_gyp_intermediates/content/common/android/hash_set.o] Error 1
make: *** Waiting for unfinished jobs....

3 个答案:

答案 0 :(得分:2)

我已经确认了我的javap,但注意到此错误的更改。我的环境是(ubuntu15.04,python2.7.6,java1.6.0_45,gcc4.8.2) 所以我改变了“external / chromium_org / base / android / jni_generator / jni_generator.py”,删除了错误。

diif如下:(“def MultipleReplace”的缩进与“class InlHeaderFileGenerator”相同)

--- a/base/android/jni_generator/jni_generator.py  
+++ b/base/android/jni_generator/jni_generator.py  
@@ -555,18 +555,24 @@ class JNIFromJavaSource(object):  
                                                                contents)  
     return JNIFromJavaSource(contents, fully_qualified_class)  

+def MultipleReplace(string, rep_dict):  
+    pattern = re.compile("|".join([re.escape(k) for k in rep_dict.keys()]), re.M)  
+    return pattern.sub(lambda x: rep_dict[x.group(0)], string)  

 class InlHeaderFileGenerator(object):  
   """Generates an inline header file for JNI integration."""  

   def __init__(self, namespace, fully_qualified_class, natives,  
                called_by_natives):  
-    self.namespace = namespace  
-    self.fully_qualified_class = fully_qualified_class  
+#    self.namespace = namespace  
+#    self.fully_qualified_class = fully_qualified_class  
+    self.namespace = MultipleReplace(namespace, {'<E>':''})  
+    self.fully_qualified_class = MultipleReplace(fully_qualified_class, {'<E>':''})  
     self.class_name = self.fully_qualified_class.split('/')[-1]  
     self.natives = natives  
     self.called_by_natives = called_by_natives  
-    self.header_guard = fully_qualified_class.replace('/', '_') + '_JNI'  
+#    self.header_guard = fully_qualified_class.replace('/', '_') + '_JNI'  
+    self.header_guard = MultipleReplace(fully_qualified_class, {'/':'_', '<E>':''}) + '_JNI'  

   def GetContent(self):  
     """Returns the content of the JNI binding file."""  

答案 1 :(得分:1)

我也有同样的问题 在对上述回答问题中的一些想法进行了跟进之后,我就解决了这个问题:

sudo apt-get remove openjdk-6-jdk  
sudo apt-get remove openjdk-8-jdk  
sudo apt-get autoremove

足以简单地使用以下命令选择oracle版本:

sudo update-alternatives --config java  
sudo update-alternatives --config javac

我必须真正去除这些包裹 目前尚不清楚我是否只需删除其中一个,我删除了两个!

答案 2 :(得分:0)

我有这个问题。这是解决方案:

sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev lib32z1 x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils python-software-properties xsltproc libx11-dev:i386 android-tools-adb android-tools-fastboot liblz4-tool gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-java6-installer
sudo apt-get install openjdk-7-jdk