错误:FAILURE:构建因异常而失败。
出了什么问题:
Execution failed for task ':app:externalNativeBuildDebug'.
Build command failed.
Error while executing process C:\Users\DELL\AppData\Local\Android\sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\DELL\Desktop\codecanyon19611273\app\build\intermediates\ndk\debug\Android.mk APP_ABI=x86 NDK_ALL_ABIS=x86 NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=C:/Users/DELL/Desktop/codecanyon19611273/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\DELL\Desktop\codecanyon19611273\app\build\intermediates\ndkBuild\debug\lib C:/Users/DELL/Desktop/codecanyon19611273/build/intermediates/ndkBuild/debug/obj/local/x86/libplayer_shared.so}
Android NDK: WARNING: Unsupported source file extensions in C:\Users\DELL\Desktop\codecanyon19611273\app\build\intermediates\ndk\debug\Android.mk for module player_shared
Android NDK: C:\Users\DELL\Desktop\codecanyon19611273\app\src\main\jni\Android.mk C:\Users\DELL\Desktop\codecanyon19611273\app\src\main\jni\Application.mk C:\Users\DELL\Desktop\codecanyon19611273\app\src\main\jni\list.sh
[x86] Compile++ : player_shared <= main.cpp
error: unable to open output file 'C:/Users/DELL/Desktop/codecanyon19611273/app/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/player_shared/C_\Users\DELL\Desktop\codecanyon19611273\app\src\main\jni\main.o': 'No such file or directory'
1 error generated.
make: *** [C:/Users/DELL/Desktop/codecanyon19611273/app/build/intermediates/ndkBuild/debug/obj/local/x86/objs-debug/player_shared/C_\Users\DELL\Desktop\codecanyon19611273\app\src\main\jni\main.o] Error 1
尝试:
使用--stacktrace
选项运行以获取堆栈跟踪。使用--info
或--debug
选项运行以获得更多日志输出。
我已将我的C ++项目与gradle
相关联,然后出现此错误。
这是我的BUILD.GRADLE; apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.getemplate.cowboyrunner"
minSdkVersion 14
targetSdkVersion 23
ndk {
moduleName "player_shared"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
externalNativeBuild {
ndkBuild {
path 'build/intermediates/ndk/debug/Android.mk'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:11.0.4'
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')
}
答案 0 :(得分:0)
您已从弃用的NDK支持( ndkCompile )切换到具有externalNativeBuild
DSL的新gradle插件。您应该遵循instructions来完成迁移,但也许您错过了一个重点:
- 将 Android.mk 文件重新定位到其他目录,例如与模块级 build.gradle 文件相同的目录。这可确保Gradle在运行clean任务时不会删除脚本文件。
- 打开Android.mk文件并编辑脚本中的所有路径,使其相对于脚本文件的当前位置。
醇>
问题是Android Studio不会将目录保留在build
下,这意味着那里的路径不可信任。