使用本地库构建Android Studio项目时出错

时间:2019-07-15 14:12:42

标签: android windows android-studio android-ndk ndk-build

我试图在Windows 10上使用NDK构建Android Studio项目,但出现以下异常: org.gradle.process.internal.ExecException:进程'ndk-build.cmd'命令以非零退出值2完成。

我使用的是ndk r11c版本,我尝试了许多解决方案,但没有一个对我有用。设置变量NDK_ROOT和NDK_PROJECTC_PATH。

这是我的build.gradle:

应用插件:“ com.android.application” 应用插件:“ io.fabric”

android {     编译版本29     defaultConfig {         applicationId“ ...”         minSdkVersion 14         targetSdkVersion 29         multiDexEnabled是         第671章         versionName“ 2.0.71”     }

dexOptions {
    jumboMode true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
}

defaultConfig {
    defaultConfig {
        vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xxhdpi', 'xxxhdpi']
    }

}

aaptOptions {
    additionalParameters "--no-version-vectors"
}

lintOptions {
    checkReleaseBuilds false     
}

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}

sourceSets.main {
    jniLibs.srcDir 'src/main/libs'
    jni.srcDirs = [] //disable automatic ndk-build call
}

task ndkBuild(type: Exec) {
    commandLine 'ndk-build.cmd', '-C', file('src/main/jni').absolutePath
}

task ndkBuildDebug(type: Exec) {
    commandLine 'ndk-build.cmd', '-C', file('src/main/jni').absolutePath, ' NDK_DEBUG=1'
}

buildTypes {
    release {
        tasks.withType(JavaCompile) {
            compileTask -> compileTask.dependsOn ndkBuild
        }
    }
    debug {
        tasks.withType(JavaCompile) {
            compileTask -> compileTask.dependsOn ndkBuildDebug
        }
    }
}

splits {
    abi {
        enable true
        reset()
        include 'armeabi-v7a', 'x86'
        universalApk false
    }
}
project.ext.versionCodes = ['armeabi-v7a': 2, 'x86': 8]

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        output.versionCodeOverride =
                project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + defaultConfig.versionCode

        outputFileName = output.outputFileName.replace(project.name,
                project.name + "-" +
                        defaultConfig.versionName + "-" + output.versionCodeOverride)
    }
}

dependencies {
    implementation 'com.android.support:multidex:1.0.3'
    implementation files('libs/QtAndroid-bundled.jar')
    implementation files('libs/sqlcipher.jar')
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:percent:28.0.0'
    implementation 'com.google.android.gms:play-services-places:16.1.0'
    implementation('com.google.http-client:google-http-client:1.29.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    implementation 'com.googlecode.libphonenumber:libphonenumber:7.4.0'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
        transitive = true
    }
    implementation project(":dns")
}

}

应用插件:“ com.google.gms.google-services”

0 个答案:

没有答案
相关问题