[TIMOB-15263] Android: Titanium SDK and Modules will not compile with (latest) Android NDK r9
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-09-27T22:40:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 20, 2013 Sprint 20 Core, Release 3.1.4, Release 3.2.0 |
Components | Android |
Labels | android, module, qe-3.1.3, triage |
Reporter | Eric Wing |
Assignee | Matt Langston |
Created | 2013-09-17T22:33:20.000+0000 |
Updated | 2015-01-08T17:53:45.000+0000 |
Description
Compiling a Titanium SDK or a Titanium Android module with the latest Android NDK (r9) which was released in July does not work.
I believe that in your C++ code generation, you are creating invalid C++ which may have been previously allowed, but is now an error by the current version of the Android gcc compiler.
We need access to the latest NDK and gcc toolchain for access to the latest and greatest Android features.
The bug is easy to reproduce. Just download the latest Android NDK and create a brand new Titanium module for Android (following your documentation). Below are the steps and the failure output.
export ANDROID_SDK_ROOT=/Library/Frameworks/Android/android-sdk/
export ANDROID_NDK_ROOT=/Library/Frameworks/Android/android-ndk-r9/
export ANDROID_NDK=/Library/Frameworks/Android/android-ndk-r9/
1. Compile SDK
run scons
scons
2. Create and compile module
~/Library/Application\ Support/Titanium/mobilesdk/osx/3.1.2.GA/titanium.py create --platform=android --type=module --name=testr9 --id=co.lanica.testr9 --android=$ANDROID_SDK_ROOT
run ant
ant
Buildfile: /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build.xml
python.set.exec:
python.check:
[echo] Testing for Python
[exec] Python 2.7.2
init:
[mkdir] Created dir: /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/classes
[mkdir] Created dir: /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/dist
process.annotations:
[mkdir] Created dir: /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/json
[javac] Compiling 2 source files to /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/classes
[javac] org/appcelerator/titanium/view/TiUIView.class(org/appcelerator/titanium/view:TiUIView.class): warning: Cannot find annotation method 'value()' in type 'android.annotation.SuppressLint': class file for android.annotation.SuppressLint not found
[javac] org/appcelerator/titanium/TiApplication.class(org/appcelerator/titanium:TiApplication.class): warning: Cannot find annotation method 'value()' in type 'android.annotation.SuppressLint'
[javac] Note: [KrollBindingGen] Running Kroll binding generator.
[javac] Note: [KrollBindingGen] No binding data found, creating new data file: org.appcelerator.titanium.bindings/testr9.json
[javac] Note: [KrollBindingGen] Found binding for proxy Example
[javac] Note: [KrollBindingGen] Found binding for module Testr9
[javac] Note: [KrollBindingGen] Generating JSON: /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/json/org/appcelerator/titanium/bindings/testr9.json
[javac] warning: The following options were not recognized by any processor: '[kroll.checkTiContext]'
[javac] org/appcelerator/titanium/view/TiUIView.class(org/appcelerator/titanium/view:TiUIView.class): warning: Cannot find annotation method 'value()' in type 'android.annotation.SuppressLint': class file for android.annotation.SuppressLint not found
[javac] org/appcelerator/titanium/TiApplication.class(org/appcelerator/titanium:TiApplication.class): warning: Cannot find annotation method 'value()' in type 'android.annotation.SuppressLint'
[javac] Note: /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/src/co/lanica/testr9/ExampleProxy.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 2 warnings
generate.v8.bindings:
[java] Generating /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/jni/co.lanica.testr9.Testr9Module.h
[java] Generating /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/jni/co.lanica.testr9.Testr9Module.cpp
[java] Generating /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/jni/co.lanica.testr9.ExampleProxy.h
[java] Generating /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/jni/co.lanica.testr9.ExampleProxy.cpp
generate.bindings:
pre.compile:
js.compile:
ndk.build:
[copy] Copying 1 file to /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated
[copy] Copying 1 file to /Users/ewing/Source/LANICA/APPC/BUGS/AndroidModule_r9/testr9/build/generated/jni
[mkdir] Created dir: /var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated
[copy] Copying 11 files to /var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated
[exec] Android NDK: WARNING:jni/Android.mk:co.lanica.testr9: non-system libraries in linker flags: -lkroll-v8
[exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
[exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
[exec] Android NDK: current module
[exec] Android NDK: WARNING:jni/Android.mk:co.lanica.testr9: non-system libraries in linker flags: -lkroll-v8
[exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
[exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
[exec] Android NDK: current module
[exec] Android NDK: WARNING:jni/Android.mk:co.lanica.testr9: non-system libraries in linker flags: -lkroll-v8
[exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
[exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
[exec] Android NDK: current module
[exec] jni/Android.mk:32: warning: overriding commands for target /private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/KrollGeneratedBindings.cpp'
[exec] jni/Android.mk:32: warning: ignoring old commands for target
/private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/KrollGeneratedBindings.cpp'
[exec] jni/Android.mk:35: warning: overriding commands for target /private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/BootstrapJS.cpp'
[exec] jni/Android.mk:35: warning: ignoring old commands for target
/private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/BootstrapJS.cpp'
[exec] jni/Android.mk:32: warning: overriding commands for target /private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/KrollGeneratedBindings.cpp'
[exec] jni/Android.mk:32: warning: ignoring old commands for target
/private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/KrollGeneratedBindings.cpp'
[exec] jni/Android.mk:35: warning: overriding commands for target /private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/BootstrapJS.cpp'
[exec] jni/Android.mk:35: warning: ignoring old commands for target
/private/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T/ewing/testr9-generated/BootstrapJS.cpp'
[exec] Compile++ thumb : co.lanica.testr9 <= co.lanica.testr9.ExampleProxy.cpp
[exec] In file included from jni/co.lanica.testr9.ExampleProxy.cpp:12:0:
[exec] /Users/ewing/Library/Application Support/Titanium/mobilesdk/osx/3.1.2.GA/android/native/include/AndroidUtil.h: In destructor 'titanium::LogTimer::~LogTimer()':
[exec] /Users/ewing/Library/Application Support/Titanium/mobilesdk/osx/3.1.2.GA/android/native/include/AndroidUtil.h:57:3: warning: format '%d' expects argument of type 'int', but argument 5 has type 'long int' [-Wformat]
[exec] jni/co.lanica.testr9.ExampleProxy.cpp: In static member function 'static v8::Handle<v8::Value> co::lanica::testr9::testr9::ExampleProxy::setMessage(const v8::Arguments&)':
[exec] jni/co.lanica.testr9.ExampleProxy.cpp:129:4: error: format not a string literal and no format arguments [-Werror=format-security]
[exec] jni/co.lanica.testr9.ExampleProxy.cpp: In static member function 'static v8::Handle<v8::Value> co::lanica::testr9::testr9::ExampleProxy::getMessage(const v8::Arguments&)':
[exec] jni/co.lanica.testr9.ExampleProxy.cpp:194:4: error: format not a string literal and no format arguments [-Werror=format-security]
[exec] jni/co.lanica.testr9.ExampleProxy.cpp: In static member function 'static v8::Handle<v8::Value> co::lanica::testr9::testr9::ExampleProxy::printMessage(const v8::Arguments&)':
[exec] jni/co.lanica.testr9.ExampleProxy.cpp:246:4: error: format not a string literal and no format arguments [-Werror=format-security]
[exec] jni/co.lanica.testr9.ExampleProxy.cpp: In static member function 'static v8::Handle<v8::Value> co::lanica::testr9::testr9::ExampleProxy::getter_message(v8::Local<v8::String>, const v8::AccessorInfo&)':
[exec] jni/co.lanica.testr9.ExampleProxy.cpp:314:4: error: format not a string literal and no format arguments [-Werror=format-security]
[exec] jni/co.lanica.testr9.ExampleProxy.cpp: In static member function 'static void co::lanica::testr9::testr9::ExampleProxy::setter_message(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::AccessorInfo&)':
[exec] jni/co.lanica.testr9.ExampleProxy.cpp:373:4: error: format not a string literal and no format arguments [-Werror=format-security]
[exec] cc1plus: some warnings being treated as errors
[exec]
[exec] make: *** [/var/folders/w0/6ybnr6311nsb21462hkpf3400000gn/T//ewing/testr9-generated/obj/local/armeabi/objs/co.lanica.testr9/co.lanica.testr9.ExampleProxy.o] Error 1
BUILD FAILED
/Users/ewing/Library/Application Support/Titanium/mobilesdk/osx/3.1.2.GA/module/android/build.xml:326: The following error occurred while executing this line:
/Users/ewing/Library/Application Support/Titanium/mobilesdk/osx/3.1.2.GA/module/android/build.xml:281: exec returned: 2
Total time: 7 seconds
Tested and verified the *issue exists* with: Appcelerator Studio, build: 3.1.3.201309132456 Titanium SDK, build:3.1.3.GA android-ndk-r9
Tested and verified the issue exists with: Titanium Studio, build: 3.1.3.201309132423 Titanium SDK, build:3.1.1.GA ADT Version: 22.2.1.v201309180102-833290 Eclipse C/C++ Development Tools Version: 8.0.2.201202111925 android-ndk-r9 BUILD FAILED /Library/Application Support/Titanium/mobilesdk/osx/3.1.1.GA/module/android/build.xml:326: The following error occurred while executing this line: /Library/Application Support/Titanium/mobilesdk/osx/3.1.1.GA/module/android/build.xml:281: exec returned: 2
The android-ndk-r9 changed ndk-build defaults to compile code with format string protection. This means NDK r9 changed a compiler warning into an error. The simple fix is to change the error back into a warning by setting LOCAL_DISABLE_FORMAT_STRING_CHECKS=true in the module's Android.mk. A more extensive and robust fix would be to go through all of our native code and change the logging statements from "char *" to "const char *", which although straightforward would entail many changes. I decided that our time is better spent focussing on ti.next than and making this more significant change.
master: https://github.com/appcelerator/titanium_mobile/pull/4743 3_1_X: https://github.com/appcelerator/titanium_mobile/pull/4744 This ticket also fixes a bug (with no ticket) whereby the Titanium SDK itself cannot compile using NDK r9 due to the same issue as this bug. Here are the test case steps: 1. Create a native Android module: ~/Library/Application\ Support/Titanium/mobilesdk/osx/3.1.3.GA/titanium.py create --platform=android --type=module --name=timob15263 --id=com.appcelerator.timob15263 --android=$ANDROID_SDK_HOME 2. cd timob15263 3. ant 4. The build will fail with this error:
5. Apply the fix for this bug. 6. cd .. 7. rm -rf timob15263 8. Repeat steps 1 through 3 and the build will succeed, which demonstrates the bug has been fixed.
Followed Matt's test steps & the build was successfull. Closing. Environment: Appcel Studio : 3.2.0.201311150806 Ti SDK : 3.2.0.v20131114184328 Mac OSX : 10.8.5 Alloy : 1.3.0 CLI - 3.2.0
I get this following warning: ndk.build: [copy] Copying 1 file to C:\Users\saravanan\Documents\Titanium_Studio_Workspace\calc\build\generated [copy] Copying 1 file to C:\Users\saravanan\Documents\Titanium_Studio_Workspace\calc\build\generated\jni [copy] Copying 11 files to C:\Users\SARAVA~1\AppData\Local\Temp\saravanan\calc-generated [exec] Android NDK: WARNING:jni/Android.mk:com.test.calc: non-system libraries in linker flags: -lkroll-v8 [exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES [exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the [exec] Android NDK: current module [exec] jni/Android.mk:32: warning: overriding commands for target
C:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:32: warning: ignoring old commands for target
C:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:35: warning: overriding commands for targetC:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/BootstrapJS.cpp' [exec] jni/Android.mk:35: warning: ignoring old commands for target
C:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/BootstrapJS.cpp' [exec] Android NDK: WARNING:jni/Android.mk:com.test.calc: non-system libraries in linker flags: -lkroll-v8 [exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES [exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the [exec] Android NDK: current module [exec] jni/Android.mk:32: warning: overriding commands for targetC:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:32: warning: ignoring old commands for target
C:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:35: warning: overriding commands for targetC:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/BootstrapJS.cpp' [exec] jni/Android.mk:35: warning: ignoring old commands for target
C:/Users/SARAVA~1/AppData/Local/Temp/saravanan/calc-generated/BootstrapJS.cpp' [exec] Android NDK: WARNING:jni/Android.mk:com.test.calc: non-system libraries in linker flags: -lkroll-v8 [exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES [exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the [exec] Android NDK: current module [exec] [armeabi] Compile++ thumb: com.test.calc <= com.test.calc.CalcModule.cpp [exec] In file included from jni/com.test.calc.CalcModule.cpp:12:0: [exec] C:\Users\saravanan\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA/android/native/include/AndroidUtil.h: In destructor 'titanium::LogTimer::~LogTimer()': [exec] C:\Users\saravanan\AppData\Roaming\Titanium\mobilesdk\win32\3.1.3.GA/android/native/include/AndroidUtil.h:57:3: warning: format '%d' expects argument of type 'int', but argument 5 has type 'long int' [-Wformat] [exec] jni/com.test.calc.CalcModule.cpp: In static member function 'static v8::HandleSorry, In 3.2.1. GA it is fixed.
This issue is not fixed on the Windows 64bit version (3.2.1.201402041146 with all updates).. Buildfile: C:\Users\dmegarry_2\Downloads\TitaniumAnimator-master\android\build.xml python.set.exec: python.check: [echo] Testing for Python [exec] Python 2.7.6 init: process.annotations: generate.v8.bindings: [java] Generating C:\Users\dmegarry_2\Downloads\TitaniumAnimator-master\android\build\generated\jni\com.animecyc.animator.AnimatorModule.h [java] Generating C:\Users\dmegarry_2\Downloads\TitaniumAnimator-master\android\build\generated\jni\com.animecyc.animator.AnimatorModule.cpp generate.bindings: pre.compile: js.compile: ndk.build: [copy] Copying 9 files to C:\Users\DMEGAR~1\AppData\Local\Temp\dmegarry_2\animator-generated [exec] Android NDK: WARNING:jni/Android.mk:com.animecyc.animator: non-system libraries in linker flags: -lkroll-v8 [exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES jni/Android.mk:35: warning: overriding commands for target
C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:35: warning: ignoring old commands for target
C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp'Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the [exec] Android NDK: current module [exec] jni/Android.mk:38: warning: overriding commands for targetC:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/BootstrapJS.cpp' [exec] jni/Android.mk:38: warning: ignoring old commands for target
C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/BootstrapJS.cpp' [exec] jni/Android.mk:35: warning: overriding commands for targetC:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:35: warning: ignoring old commands for target
C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp' [exec] jni/Android.mk:38: warning: overriding commands for targetC:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/BootstrapJS.cpp' [exec] jni/Android.mk:38: warning: ignoring old commands for target
C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/BootstrapJS.cpp' [exec] Android NDK: WARNING:jni/Android.mk:com.animecyc.animator: non-system libraries in linker flags: -lkroll-v8 [exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES [exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the [exec] Android NDK: current module [exec] Android NDK: WARNING:jni/Android.mk:com.animecyc.animator: non-system libraries in linker flags: -lkroll-v8 [exec] Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES [exec] Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the [exec] Android NDK: current module [exec] [armeabi] Compile++ thumb: com.animecyc.animator <= com.animecyc.animator.AnimatorModule.cpp [exec] 'gperf' is not recognized as an internal or external command, [exec] operable program or batch file. [exec] make.exe: *** [C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp] Error 1 [exec] make.exe: *** Deleting file `C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp' [exec] gperf -L C++ -E -t "C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.gperf" > "C:/Users/DMEGAR~1/AppData/Local/Temp/dmegarry_2/animator-generated/KrollGeneratedBindings.cpp" BUILD FAILED C:\Users\dmegarry_2\AppData\Roaming\Titanium\mobilesdk\win32\3.2.1.GA\module\android\build.xml:326: The following error occurred while executing this line: C:\Users\dmegarry_2\AppData\Roaming\Titanium\mobilesdk\win32\3.2.1.GA\module\android\build.xml:281: exec returned: 2 Total time: 2 secondsSame here. I do have this problem on windows 7 Ti Mobile 3.2.2.GA. I also checked and LOCAL_DISABLE_FORMAT_STRING_CHECKS=true is being generated on Android.mk file.
Having issues as well. Using the latest 3.4.1.GA, as well as the versions discussed in this thread (3.2.1.GA, 3.2.2.GA). I create a project with
ti create -t module -p android
and build right after creating it. It throws a lot of warnings, and then throws a ton of syntax errors: [exec] In file included from jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp:10:0: [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.h:22:1: error: expected class-name before '{' token [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp: In constructor 'com::atticoos::titanium::okhttp::titaniumokhttp::ExampleProxy::ExampleProxy(jobject)': [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp:38:65: error: expected class-name before '(' token [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp:38:65: error: expected '{' before '(' token [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp: At global scope: [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp:39:1: error: expected constructor, destructor, or type conversion before '{' token [exec] jni/com.atticoos.titanium.okhttp.ExampleProxy.cpp: In static member function 'static void com::atticoos::titanium::okhttp::titaniumokhttp::ExampleProxy::dispose()': and the list goes on