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 から ./gradlew compileArmDebugJava を実行すると、プロジェクトは正常にコンパイルされます。
アンドロイドスタジオのエラー:
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
}