[TIMOB-25932] Android: Cannot build SDK with JDK 10 (missing javah tool)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-08-20T15:59:49.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | android, ant, build, jdk, sdk |
Reporter | Chris Barber |
Assignee | Joshua Quick |
Created | 2018-04-04T19:04:55.000+0000 |
Updated | 2018-10-15T20:25:33.000+0000 |
Description
*Summary:*
If you attempt to build the Titanium SDK (ie: titanium_mobile) with JDK 10 installed, the build will fail due to a missing "javah" tool. This tool has been removed in JDK 10.
*Steps to reproduce:*
Enter:
*Result:*
Build fails due to missing "javah" tool.
*Work-Around:*
Build with JDK 8 or 9.
*Recommended Solution:*
Remove Titanium's usage of the "javah" tool and the
Instal JDK 10 if not done already.
Open the terminal.
cd
to the titanium_mobile/build
directory.
Enter: node scons.js build android
*Result:*
Build fails due to missing "javah" tool.
*Work-Around:*
Build with JDK 8 or 9.
*Recommended Solution:*
Remove Titanium's usage of the "javah" tool and the #include
's to the generated headers files. They're not needed.
The generated header files and function prototypes are useless by themselves. We have to create the function implementation ourselves, which we've already done and they're already publicly exported via JNIEXPORT
in their respective C++ files. Since the implementation side already exports the functions, the function prototypes are not needed.
https://github.com/appcelerator/titanium_mobile/blob/master/android/runtime/v8/src/native/JSDebugger.cpp
https://github.com/appcelerator/titanium_mobile/blob/master/android/runtime/v8/src/native/V8Object.cpp
https://github.com/appcelerator/titanium_mobile/blob/master/android/runtime/v8/src/native/V8Runtime.cpp
----
*Original Description:*
JDK 10 has dropped the javah
tool (http://openjdk.java.net/jeps/313) which is required by our tooling when building the Android platform. We need to use javac
's -h
flag instead. javah
generated the header files from the compiled .class
files in the jars, however javac -h
used the original .java
files.
We'll likely have to move the header generation out of the native compile step and into the Java compile step. We can do this by specifying the nativeheaderdir
attribute in the javac
task in the common.xml
file. However, the nativeheaderdir
attribute is only supported in ant 1.9.8+ (https://ant.apache.org/manual/Tasks/javac.html) and we ship ant
1.8.0 with Titanium. The Android build also depends on ant-contrib
and ant-nodeps
which may not be compatible with ant 1.9.8 or newer.
In the meantime, we'll have to use JDK 9 to build the Titanium SDK.
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10257
Verified the fix on master 7.5 version. build successfully built and run on android in Mac as well as windows. Closing.