Android 导入项目时遇到的JNI和NDK问题

来源:互联网 发布:乾坤量能指标源码 编辑:程序博客网 时间:2024/05/22 13:22

android studio在导入一些调用C/C++的android项目时,会遇到有关JNI的问题,例如导入下面这个项目

https://github.com/handheldgroup/android-serialport-api

会遇到这样的问题

Error:(12, 0) Error: NDK integration is deprecated in the current plugin.  Consider trying the new experimental plugin.  For details, see http://tools.android.com/tech-docs/new-build-system/gradle-experimental.  Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration.

这个问题的解决办法在这

http://stackoverflow.com/questions/31979965/after-updating-android-studio-to-version-1-3-0-i-am-getting-ndk-integration-is

按照上面完成之后可以编译通过了,但是run一下会出现下面的问题

Error:(97) undefined reference to `__android_log_print'

网上各种找资料,试了很多方法之后都没用,最后用这个里面的第三个回答解决了

http://stackoverflow.com/questions/4455941/undefined-reference-to-android-log-print

回答里面的前两种我也试了,都不行,第三种修改Android.mk

android {    defaultConfig {        ndk {            moduleName "your_module_name"            ldLibs "log"//添加这一句代码就可以了        }    }}

就可以跑起来了

0 0
原创粉丝点击