将带有jni的Eclipse项目导入AndroidStudio遇到的问题

当然前提是本地已经配置好了ndk的环境

1. NDK integration is deprecated in the current plugin

首次编译遇到一个错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugNdk'.
> 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 "$USE_DEPRECATED_NDK=true" in gradle.properties to continue using the current NDK integration.

解决

先在module下新建文件,gradle.properties

文件中写上一句 android.useDeprecatedNdk=true

然后重新build就没这个问题了

2. Native C/C++ source code is found, but it seems that NDK option is not configured

Warning: Native C/C++ source code is found, but it seems that NDK option is not configured.  Note that if you have an Android.mk, it is not used for compilation.  The recommended workaround is to remove the default jni source code directory by adding: 
 android {
    sourceSets {
        main {
            jni.srcDirs = []
        }
    }
}
to build.gradle, manually compile the code with ndk-build, and then place the resulting shared object in src/main/jniLibs.

build失败在Gradle Console中会打印这个信息

解决

其中一种方法就是,就按他提示的吧,加上

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

再次build ,:

BUILD SUCCESSFUL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值