我的android项目有问题,我从一台计算机移动到另一台计算机。当然,在我更改计算机和Android Studio版本(从1.5到2.2)之前,一切正常。现在,当我想运行项目时,我遇到了这个错误:
错误:任务':app:ndkBuild'执行失败。 处理' e:\ Android \ ndk \ android-ndk-r12b \ ndk-build.cmd''完成非零退出值2
这是我的gradle构建:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxx.crossexample"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
task ndkBuild(type: Exec) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
commandLine "e:\\Android\\ndk\\android-ndk-r12b\\ndk-build.cmd", '-B', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
}
我的local.properies
sdk.dir=e\:\\Android\\sdk
ndk.dir=e\:\\Android\\ndk\\android-ndk-r12b
我的代码有什么问题吗?
UPDATE 这是gradle控制台日志:
> Executing tasks: [:app:clean, :app:generateDebugSources,
> :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies,
> :app:generateDebugAndroidTestSources, :app:assembleDebug]
>
> Configuration on demand is an incubating feature. Incremental java
> compilation is an incubating feature. :app:clean
> :app:buildInfoDebugLoader :app:preBuild UP-TO-DATE :app:preDebugBuild
> UP-TO-DATE :app:checkDebugManifest
> :app:prepareComAndroidSupportAnimatedVectorDrawable2320Library
> :app:prepareComAndroidSupportAppcompatV72320Library
> :app:prepareComAndroidSupportSupportV42320Library
> :app:prepareComAndroidSupportSupportVectorDrawable2320Library
> :app:prepareDebugDependencies :app:compileDebugAidl
> :app:compileDebugRenderscript :app:generateDebugBuildConfig
> :app:generateDebugResValues :app:generateDebugResources
> :app:mergeDebugResources :app:processDebugManifest
> :app:processDebugResources :app:generateDebugSources
> :app:mockableAndroidJar UP-TO-DATE :app:preDebugUnitTestBuild
> UP-TO-DATE :app:prepareDebugUnitTestDependencies
> :app:preDebugAndroidTestBuild UP-TO-DATE
> :app:prepareDebugAndroidTestDependencies
> :app:compileDebugAndroidTestAidl :app:processDebugAndroidTestManifest
> :app:compileDebugAndroidTestRenderscript
> :app:generateDebugAndroidTestBuildConfig
> :app:generateDebugAndroidTestResValues
> :app:generateDebugAndroidTestResources
> :app:mergeDebugAndroidTestResources
> :app:processDebugAndroidTestResources
> :app:generateDebugAndroidTestSources
> :app:incrementalDebugJavaCompilationSafeguard :app:ndkBuild make:
> Entering directory
> `E:/AndroidStudioProjects/CrossExample/CrossExample/app/src/main/jni'
>
> make: *** No rule to make target
> `E:/AndroidStudioProjects/CrossExample/app/src/main/jni/SuperpoweredExample.cpp',
> needed by
> `E:/AndroidStudioProjects/CrossExample/CrossExample/app/src/main/obj/local/arm64-v8a/objs/SuperpoweredExample/E_/AndroidStudioProjects/CrossExample/app/src/main/jni/SuperpoweredExample.o'.
> Stop.
>
> make: Leaving directory
> `E:/AndroidStudioProjects/CrossExample/CrossExample/app/src/main/jni'
> :app:ndkBuild FAILED
>
> FAILURE: Build failed with an exception.
>
> * What went wrong: Execution failed for task ':app:ndkBuild'.
> > Process 'command 'e:\Android\ndk\android-ndk-r11c\ndk-build.cmd'' finished with non-zero exit value 2
>
> * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
>
> BUILD FAILED
>
> Total time: 7.778 secs
答案 0 :(得分:0)
在我的情况下,从命令行运行构建工作正在运行,但不是来自gui。 我通过升级Android Build工具解决了这个问题。 也许NDK与之前的Android Build工具不兼容。