Android 安卓工作室可以';无法编译,但gradle cli可以编译
我在Mac上的Android Studio 0.5.7出现了奇怪的错误。我无法使用gradle和ndk build编译我的项目。它失败,出现以下错误:Android 安卓工作室可以';无法编译,但gradle cli可以编译,android,android-ndk,android-studio,gradlew,Android,Android Ndk,Android Studio,Gradlew,我在Mac上的Android Studio 0.5.7出现了奇怪的错误。我无法使用gradle和ndk build编译我的项目。它失败,出现以下错误: FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':SKG:ndkBuild'. A problem occurred starting process 'command 'ndk-build'' 但是,当我从CLI运行.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':SKG:ndkBuild'.
A problem occurred starting process 'command 'ndk-build''
但是,当我从CLI运行./gradlew compileArmDebugJava时,项目已成功编译
android studio中的错误:
Executing tasks: [:SKG:compileArmDebugJava]
Parallel execution with configuration on demand is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:SKG:preBuild
:SKG:preArmDebugBuild
:SKG:checkArmDebugManifest
:SKG:preArmReleaseBuild
:SKG:preArmv7DebugBuild
:SKG:preArmv7ReleaseBuild
:SKG:preFatDebugBuild
:SKG:preFatReleaseBuild
:SKG:preMipsDebugBuild
:SKG:preMipsReleaseBuild
:SKG:preX86DebugBuild
:SKG:preX86ReleaseBuild
:SKG:prepareComAndroidSupportAppcompatV71910Library UP-TO-DATE
:SKG:prepareArmDebugDependencies
:SKG:compileArmDebugAidl UP-TO-DATE
:SKG:compileArmDebugRenderscript UP-TO-DATE
:SKG:generateArmDebugBuildConfig UP-TO-DATE
:SKG:mergeArmDebugAssets UP-TO-DATE
:SKG:generateArmDebugResValues UP-TO-DATE
:SKG:generateArmDebugResources UP-TO-DATE
:SKG:mergeArmDebugResources UP-TO-DATE
:SKG:processArmDebugManifest UP-TO-DATE
:SKG:processArmDebugResources UP-TO-DATE
:SKG:generateArmDebugSources UP-TO-DATE
:SKG:ndkBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':SKG:ndkBuild'.
> A problem occurred starting process 'command 'ndk-build''
* 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: 16.103 secs
从cli成功生成
./gradlew compileArmDebugJava
Parallel execution is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:SKG:preBuild
:SKG:preArmDebugBuild
:SKG:checkArmDebugManifest
:SKG:preArmReleaseBuild
:SKG:preArmv7DebugBuild
:SKG:preArmv7ReleaseBuild
:SKG:preFatDebugBuild
:SKG:preFatReleaseBuild
:SKG:preMipsDebugBuild
:SKG:preMipsReleaseBuild
:SKG:preX86DebugBuild
:SKG:preX86ReleaseBuild
:SKG:prepareComAndroidSupportAppcompatV71910Library UP-TO-DATE
:SKG:prepareArmDebugDependencies
:SKG:compileArmDebugAidl UP-TO-DATE
:SKG:compileArmDebugRenderscript UP-TO-DATE
:SKG:generateArmDebugBuildConfig UP-TO-DATE
:SKG:mergeArmDebugAssets UP-TO-DATE
:SKG:generateArmDebugResValues UP-TO-DATE
:SKG:generateArmDebugResources UP-TO-DATE
:SKG:mergeArmDebugResources UP-TO-DATE
:SKG:processArmDebugManifest UP-TO-DATE
:SKG:processArmDebugResources UP-TO-DATE
:SKG:generateArmDebugSources UP-TO-DATE
:SKG:ndkBuild
make: Entering directory `/...my path.../SKG/src/main/jni'
[armeabi] Install : libcrypto.so => libs/armeabi/libcrypto.so
[armeabi] Install : libdatabase_sqlcipher.so => libs/armeabi/libdatabase_sqlcipher.so
[armeabi] Install : libgenerate.so => libs/armeabi/libgenerate.so
[armeabi] Install : libsqlcipher_android.so => libs/armeabi/libsqlcipher_android.so
[armeabi] Install : libssl.so => libs/armeabi/libssl.so
[armeabi] Install : libstlport_shared.so => libs/armeabi/libstlport_shared.so
make: Leaving directory `/...my path.../src/main/jni'
:SKG:compileArmDebugJava UP-TO-DATE
BUILD SUCCESSFUL
Total time: 16.327 secs
这是我的build.gradle文件:
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'android'
android {
compileSdkVersion 16
buildToolsVersion '19.0.3'
defaultConfig {
minSdkVersion 9
targetSdkVersion 16
versionCode 28
versionName "2.2"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
debuggable false
jniDebugBuild false
}
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = []
}
defaultConfig {
ndk {
moduleName "generate"
}
}
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
}
mips {
ndk {
abiFilter "mips"
}
}
armv7 {
ndk {
abiFilter "armeabi-v7a"
}
}
arm {
ndk {
abiFilter "armeabi"
}
}
fat
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
}
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C', file('src/main/jni/').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
已解决,删除了最后一行“/”,更改了此行:
commandLine 'ndk-build', '-C', file('src/main/jni/').absolutePath
为此:
commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath
如果你使用的是windows,你需要在gradle.build:
命令行ndkCommand,'-C',file('src/main/jni')。绝对路径,'clean'
但如果您使用了其他操作系统,如Linux或Mac,则需要编写以下内容:
命令行ndkCommand,'-C',file('src/main/jni/')。absolutePath,'clean'
您可以为自己的问题添加答案,而不是将其嵌入问题中,以使其他人更清楚地知道您找到了解决方案。当时,当我找到答案时,我无法回答我的问题,因为这样做我的分数很低。即使我将文件路径设置为没有尾随斜杠,我也会遇到同样的问题。你用什么系统?窗户?linux?对我来说,“libs/armeabi-v7a/libmylibrary.so”文件被生成到/jni/文件夹中,这是错误的,它应该在目录上。有没有办法在适当的文件夹中生成它们?用于回答您自己的问题。