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.
这个问题的解决办法在这
按照上面完成之后可以编译通过了,但是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"//添加这一句代码就可以了
}
}
}
就可以跑起来了
本文介绍了在使用Android Studio导入含有C/C++代码的项目时,遇到的关于JNI问题的解决方案。针对“undefined reference to `__android_log_print`”错误,通过在Android.mk文件中添加ldLibslog配置来解决。
3164

被折叠的 条评论
为什么被折叠?



