android 学习用NDK开发出现各种的Error

学习用NDK进行开发,运行到手机上报了个错,先把错误日志贴上:

1.Error: Flag android.useDeprecatedNdk is no longer supported and will be removed in the next version of Android Studio.  Please switch to a supported build system.  

  1.   Consider using CMake or ndk-build integration. For more information, go to:  
  2.    https://d.android.com/r/studio-ui/add-native-code.html#ndkCompile  
  3.    To get started, you can use the sample ndk-build script the Android  
  4.    plugin generated for you at:  
  5.    E:\SwimmingSpace\ndktest\build\intermediates\ndk\debug\Android.mk  
  6.   Alternatively, you can use the experimental plugin:  
  7.    https://developer.android.com/r/tools/experimental-plugin.html  
  8.   To continue using the deprecated NDK compile for another 60 days, set   
  9.   android.deprecatedNdkCompileLease=1515138691572 in gradle.properties  

刚开始开这个错误日志有点懵了,但是我们仔细看一下会发现android.useDeprecatedNdk不在被支持了,但是在日志后面给了我们一个解决办法To continue using the deprecated NDK compile for another 60 days, set 

  android.deprecatedNdkCompileLease=1515138691572 in gradle.properties大概意思是想要继续使用已弃用的NDK编译60天,在gradle.properties文件里把android.useDeprecatedNdk去掉换成android.deprecatedNdkCompileLease=1515138691572就行了,我猜有肯能每个人错误日志里得到android.deprecatedNdkCompileLease=1515138691572不一定一样,所以尽量使用自己错日志里的进行运行。


2. Error: Your project contains C++ files but it is not using a supported native build system

然后再在文件build.gradle(Module:app)里面的buildTypes类中添加一个这样的方法

sourceSets {
    main {
        jni.srcDirs = []
    }
}

如下图所示
这里写图片描述


这样就可以编译成功了

大家可以试一下,有任何问题可以随时和我留言,我会尽快给大家解答,谢谢大家





猜你喜欢

转载自blog.csdn.net/tanghongchang123/article/details/79865238