Peter Teoh
Peter Teoh

Reputation: 6753

Error during Android platform compilation: "extra tokens at end of #ifndef directive [-Werror]"

This is Android source code compilation.

After repeating "repo sync" over several nights, and then "make -j4" I will get the following errors on each of the different days of compilation. (My Java is version 6u45 from Oracle JDK, and host machine is Linux Ubuntu 64-bit LTS 14.04). But doing the same thing (compilation from "repo sync") will not result in an error in another Ubuntu 14.04 LTS (64-bit) and I can even execute "emulator" to start the asop_arm-eng emulator image on another machine. Something must be wrong with first machine.

Googling does not reveal any similar bugs, someone please help?

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....

Upvotes: 0

Views: 893

Answers (3)

kfc
kfc

Reputation: 617

I had this issue to. Here is solution:

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

Upvotes: 0

Jiaxi He
Jiaxi He

Reputation: 19

I have configed my javap but noting change for this error. My enviornment is (ubuntu15.04, python2.7.6, java1.6.0_45, gcc4.8.2) So I change "external/chromium_org/base/android/jni_generator/jni_generator.py", which remove the error.

diif as follows: (indent for "def MultipleReplace" is same with "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."""  

Upvotes: 2

Stephen Munnings
Stephen Munnings

Reputation: 21

I too had this same issue.
After following up some of the ideas in the above response question, here is how I fixed my problem:

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

It was not enough to simply select the oracle versions using the following commands:

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

I had to actually go and remove these packages.
It is not clear if I had to remove just one or the other, I removed both!

Upvotes: 1

Related Questions