Android|AndroidStudio的JNI开发中遇到的一些问题
AndroidStudio的JNI开发中遇到的一些问题 因为公司的项目中需要使用JNI,刚好借此机会学习一下JNI的使用,参考NDK-JNI实战教程(一) 在Android Studio运行第一个NDK程序 ,遇到了一些问题,在这里整理一下问题以及解决方案。
- 在通过命令行生成.h头文件之后rebuild提示
Error:Execution failed for task ':app:clean'. > Unable to delete directory build
clean以及rebuild都卡在这个问题上,最后根据提示手动删除相应的目录,重新编译解决
NDK integration is deprecated in the current plugin
在当前module的gradle.properties文件中,添加
android.useDeprecatedNdk=true
Error: Your project contains C++ files but it is not using a supported native build system.
解决方案参考:AS配置NDK外部工具
错误提示如下:
Error:Execution failed for task ':app:compileDebugNdk'.
> Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
- build成功之后,在
build/intermediates
目录下无法生成ndk目录以及对应的so动态库文件
【Android|AndroidStudio的JNI开发中遇到的一些问题】将gradle中的sourceSets ....
注销之后重新rebuild解决。
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
//sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jni/'] } }
推荐阅读
- 热闹中的孤独
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- 放屁有这三个特征的,请注意啦!这说明你的身体毒素太多
- 一个人的旅行,三亚
- 布丽吉特,人生绝对的赢家
- 慢慢的美丽
- 尽力
- 一个小故事,我的思考。
- 家乡的那条小河
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量