Help getting the Android Java Plugin example project working (SOLVED)

Hi everyone, I’m trying to get the Android Java Plugin sample package linked to from the Unity docs on Android plugins working.

In the Plugins/Android/src folder, there is a build_plugins.sh script. The javac line is:

javac JavaClass.java -bootclasspath $ANDROID_SDK_ROOT/platforms/android-8/android.jar -d .

Because I have javac 1.8 (and the Unity docs say to use 1.6) and Android SDK level 21 on my system, I change the above line to:

javac JavaClass.java -source 1.6 -target 1.6 -bootclasspath $ANDROID_SDK_ROOT/platforms/android-21/android.jar -d .

Now the java compile step works, but I get the following errors in the NDK build step:

Do I have the wrong c++ compiler or settings? Something else wrong?

UPDATE: These errors are caused by mismatched types between variables and the corresponding format specifiers in the debug log messages in the sample package’s NativeJavaBridge.cpp file. They can be fixed by adding (unsigned int) or (int) casts as needed for the %x and %i format specifiers. On line 68 of the file, %i should be changed to %s as the debug log is printing out a string, not an int.

Here’s the fixed NativeJavaBridge.cpp in case it’s helpful to someone else. (NOTE I added the .txt extension to allow it to be uploaded here.)

2292667–154218–NativeJavaBridge.cpp.txt (3.1 KB)