如何修复AndroidStudio中的NDK构建错误

时间:2017-06-14 04:39:27

标签: android c++ android-ndk

我想将AndroidStudio中的项目构建到我的手机中,但是在Android Studio中运行按钮时。告诉我这个错误:

Error:Execution failed for task ':app:compileDebugNdk'.
> Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
 https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
 http://tools.android.com/tech-docs/new-build-system/gradle-experimental.

Build.Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "com.companyname.gamename"
        minSdkVersion 14
        targetSdkVersion 23

        ndk {
            moduleName "player_shared"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/dagger-1.2.2.jar')
    compile files('libs/javax.inject-1.jar')
    compile files('libs/nineoldandroids-2.4.0.jar')
    compile files('libs/support-v4-19.0.1.jar')
}

我该如何解决?

2 个答案:

答案 0 :(得分:1)

粘贴到build.gradle(模块:app)中的代码下面

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

buildTypes{
}

答案 1 :(得分:0)

将其粘贴到build.gradle

上方的buildTypes{}
 sourceSets {
            main {
                jni.srcDirs = []
            }
        }

buildTypes{
}