c++文件中jni库找不到报红
本來沒有問題的一個(gè)項(xiàng)目,有一天打開后c++文件中jni庫(kù)都報(bào)紅,但是并不影響運(yùn)行,但是非常影響開發(fā)。
比如
#include <jni.h>報(bào)紅,提示jni.h file not found。而且cpp文件上面有一條提
“This file is not part of the project. Please include it in the appropriate build file(build.gradle,CMakeLists.txt or Android.mk etc.) and sync the project.“
最后發(fā)現(xiàn)是cmake與gradle版本不一致,因?yàn)槠渌?xiàng)目中升級(jí)了sdk中的cmake,同時(shí)也升級(jí)了項(xiàng)目中的gradle,但是在這個(gè)項(xiàng)目中g(shù)radle并沒有升級(jí),就導(dǎo)致了問題。
問題版本:
cmake:3.10.2.xxx
gradle:com.android.tools.build:gradle:3.2.0 和 gradle-4.6-all.zip
升級(jí)gradle即可,升級(jí)后是com.android.tools.build:gradle:4.0.1 和 gradle-6.1.1-all.zip
同時(shí)注意如果使用kotlin,也需要同步升級(jí)到org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0
(原來是1.3.0,如果不升級(jí)就在apply plugin: 'kotlin-android’這里報(bào)錯(cuò))
升級(jí)后sync一下,就可以看到c++文件中不再報(bào)紅了,可以正常開發(fā)了。
總結(jié)
以上是生活随笔為你收集整理的c++文件中jni库找不到报红的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mongodb如何快速进行版本升级
- 下一篇: s3c2440移植MQTT