我已经设法在Android Studio下编译新的cocos 3.7项目(虽然不容易)。 当我在项目中添加Facebook插件时,会出现此编译错误:
Skipping task ':libcocos2dx:compileDebugAidl' as it is up-to-date (took 0.008 secs).
:libPluginProtocol:compileReleaseNdk UP-TO-DATE
:libcocos2dx:compileDebugAidl (Thread[Task worker Thread 3,5,main]) completed. Took 0.011 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':libPluginProtocol:compileReleaseNdk'.
> NDK not configured.
Download the NDK from http://developer.android.com/tools/sdk/ndk/.Then add ndk.dir=path/to/ndk in local.properties.
(On Windows, make sure you escape backslashes, e.g. C:\\ndk rather than C:\ndk)
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
我已使用“导入模块”在项目中添加了该插件,然后选择了相应的proj.android文件夹。
我尝试了什么:
jni.srcDirs = []
更改local.properties不起作用,因为这些文件会自动生成,而我添加的ndk.dir条目会丢失。
我正在从命令行编译:{{1}}
环境:cocos-js 3.7,ndk = r10c
以下是我生成的gradle文件的高峰:
项目(工作)
cocos compile -p android --android-studio
libcocos(工作)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.sharkintelligence.GameXY.google.full"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "assets"
jni.srcDirs = [] //disable automatic ndk-build call
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libcocos2dx')
compile project(':libPluginFacebook')
}
libPluginProtocol(不工作)
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
sourceSets.main {
aidl.srcDir "../java/src"
java.srcDir "../java/src"
manifest.srcFile "AndroidManifest.xml"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
答案 0 :(得分:1)
回答是设置系统变量ANDROID_NDK_HOME
。
就我而言:export ANDROID_NDK_HOME=$NDK_ROOT