NDK: How to reference native sources OUTSIDE Android project?

雨燕双飞 提交于 2019-12-24 17:13:22

问题


I'm using Android Studio 1.2.2 and just downloaded 1.3RC3, as it reputedly has full NDK support.

I have a working project while my .c / .h files remain in app/src/main/jni; however, I want them in AndroidProject/../common/src, i.e. outside the android project folder. How do I make this work?

To reiterate: this question is about EXTERNAL, NATIVE CODE; not importing external java!


回答1:


This was so simple, I didn't think to even try it at first, but it worked at once:

android{
   ...
   sourceSets.main.jni.srcDirs = ['../../common/test']
   ...
}

...which implies that the path is relative to AndroidProject/app.

A problem with this solution is that it is incompatible with a standalone Android.mk, since preventing Android.mk generation by gradle requires sourceSets.main.jni.srcDirs = [].



来源:https://stackoverflow.com/questions/31572821/ndk-how-to-reference-native-sources-outside-android-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!