I have managed to use termux-ndk(openjdk-11.0.1 ndk-r21 android-sdk(build-tools:29.0.3 platforms:android-29)) to build a project(without gradle).
Here's some problems I encountered. I think the host API level of the prebuilt JDK, NDK and SDK need to be presented.
1)Firstly I tried to build my project on a Android 8.1 device. The compilation was fine, but there was an error during linking, saying:
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/android-ndk-r21/toolchains/llvm/prebuilt/linux-aarch64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld": cannot locate symbol "glob" referenced by "/data/data/com.termux/files/home/android-ndk-r21/toolchains/aarch64-linux-android-4.9/prebuilt/linux-aarch64/bin/aarch64-linux-android-ld"...
Which I think is caused by lacking "glob" function in libc.so.
I have searched the web and found something saying glob was added to Bionic on API Level 28 (Android 9). Termux now targets API Level 24 (Android 7.0) and includes a compatibility library libandroid-glob.
https://github.com/android/ndk/issues/126
https://github.com/termux/termux-packages/tree/master/packages/libandroid-glob
2)Then I switched to a Android 10 device and encountered a error during static library build, saying:
CANNOT LINK EXECUTABLE "/data/data/com.termux/files/home/android-ndk-r21/toolchains/llvm/prebuilt/linux-aarch64/bin/llvm-ar": library "libc++_shared.so" not found
I found android-ndk-r21/toolchains/llvm/prebuilt/linux-aarch64/lib64/libc++.so.1 is the library that references libc++_shared.so. But I checked its import functions and found it doesn't import any functions from libc++_shared.so. I think there may be a problem with its build process. Anyway, I copied libc++_shared.so from <NDK_PATH>\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\lib\aarch64-linux-android\libc++_shared.so on my Windows machine and it works.
3)The third problem is trivial and it is in d8 tool, which relies 'java' in PATH environment variable.
/data/data/com.termux/files/home/android-sdk/build-tools/29.0.3/d8: line 89: exec: java: not found
I fixed it by add a symbol link, and I think it's better documented in the readme.
ln -s /data/data/com.termux/files/home/openjdk-11.0.1/bin/java /data/data/com.termux/files/usr/bin/java