将 Android Studio 更新到版本 1.3.0 后,我收到 "NDK integration is deprecated in the current plugin" 错误

After updating Android Studio to version 1.3.0 I am getting "NDK integration is deprecated in the current plugin" Error

我已经在 3 天前将我的 Android Studio 更新到版本 1.3.0

在此之前我可以使用 NDK,但现在我收到类似

的错误

Error:(50, 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.

我在项目级别找不到文件 gradle.property。

如何解决这个错误?

解决这个问题的方法如下:

  1. gradle.properties 文件添加到项目的根文件夹中
  2. 'android.useDeprecatedNdk=true' 添加到 gradle.properties 文件

这是我的 gradle.properties :

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useDeprecatedNdk=true

并将其添加到项目的根目录中:

并重建您的项目。 就是这样。

这主要发生在您将项目从 eclipse 迁移到 Android studio 时,或者当您只是在 android studio 中导入 eclipse 项目时。

出现此错误时还有一个问题,主要是您没有名为 "gradle.properties" 的文件,您需要先在项目中 create/add 然后设置

android.useDeprecatedNdk=true

已弃用 不再支持 NDK。为了避免这个错误 remove android.useDeprecatedNdk=true 并且不要做任何 white space 在项目目录中。如果错误再次出现 然后编辑 build.gradle(Module:app) 并添加如下行:

 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
sourceSets { main { jni.srcDirs = ['src/main/jni/','src/main/jniLibs/'] } }
externalNativeBuild {
    ndkBuild {
        path 'build/intermediates/ndk/debug/Android.mk'
    }
}

解决这个问题的方法如下:

转到 gradle.properties 文件到项目的根文件夹 从您的 gradle.properties 文件中删除 android.useDeprecatedNdk=true

Android 已删除 android.useDeprecatedNdk,因此它不再有效