如何修复 Android Studio 中的 NDK 构建错误

问题描述 投票:0回答:2

我想将我的项目从 Android Studio 构建到我的手机中,但是当我在 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')
}

我该如何解决?

android c++ android-ndk
2个回答
1
投票

将以下代码粘贴到您的 build.gradle 文件(模块:app)中:

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

buildTypes{
}

0
投票

将此粘贴到文件build.gradle上面

buildTypes{}

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

buildTypes {
}
© www.soinside.com 2019 - 2024. All rights reserved.