Search code examples
androideclipseandroid-ndkjava-native-interfaceandroid-studio

Android JNI won't compile without a project.properties file


I transitioned from using Eclipse to Android Studio. I discovered after hours of battle that the project.properties file that used to be generated by Eclipse was necessary for me to build the JNI component of my app.

I'm just looking for someone to explain:

  1. Why is this project.properties file necessary?
  2. Is there a way I can tweak my Android.mk so I don't need it?

The project.properties file that I need has 1 line:

target=android-10

I am doing native window API calls in my JNI code.

Edit:

I just wanted to add...without this properties file my symptoms include not being able to locate header files and libraries, such as this sample output:

Compile++ thumb  : videolibs <= video_codec_jni.cpp
/Users/spartygw/vpdsec/src/applications/VideoSend/jni/video_codec_jni.cpp:11:35: error: android/native_window.h: No such file or directory
/Users/spartygw/vpdsec/src/applications/VideoSend/jni/video_codec_jni.cpp:12:39: error: android/native_window_jni.h: No such file or directory
In file included from /Users/spartygw/vpdsec/src/applications/VideoSend/jni/../../../libraries/VideoCodec/H263.h:13,

Solution

  • The easiest workaround would be to put this one-line file in jni/.. directory manually.

    You can also add APP_PLATFORM=android-10 to your ndk-build command line.

    You can also set it in your Application.mk. Unfortunately, you cannot set this in Android.mk.