我找到了与此问题相关的不同答案,但对我没有用,所以我不确定我是否在某处添加了错误。
错误:
Gradle sync失败:没有方法签名:com.android.build.gradle.AppPlugin.getNdkFolder()适用于参数类型:()值:[]
build.gradle模块
apply plugin: 'com.android.application'
import org.apache.tools.ant.taskdefs.condition.Os
android {
compileSdkVersion 21
buildToolsVersion "21"
defaultConfig {
applicationId 'com.domain.game'
minSdkVersion 11
targetSdkVersion 11
ndk {
moduleName "cocos2dcpp_shared"
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
java.srcDirs += '../../Classes'
assets.srcDirs = ['../../Resources']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
//def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
if(Os.isFamily(Os.FAMILY_WINDOWS))
commandLine "${ndkDir}\\ndk-build.cmd",'-C', file('src/main/jni').absolutePath, '-j', Runtime.runtime.availableProcessors(), 'all'
else
commandLine "${ndkDir}/ndk-build",'-C', file('src/main/jni').absolutePath, '-j', Runtime.runtime.availableProcessors(), 'all'
}
task cleanNative(type: Exec, description: 'Clean JNI object files') {
def ndkDir = project.plugins.findPlugin('com.android.application').getNdkFolder()
if(Os.isFamily(Os.FAMILY_WINDOWS))
commandLine "${ndkDir}\\ndk-build.cmd",'-C', file('src/main/jni').absolutePath, 'clean'
else
commandLine "${ndkDir}/ndk-build",'-C', file('src/main/jni').absolutePath, 'clean'
}
clean.dependsOn 'cleanNative'
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative
}
dependencies {
compile project(':googleplayservices_lib')
compile files('libs/OpenIAB-0.9.6-sync2.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/GiftizSDK_1.5.0.jar')
}
build.gradle项目
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
gradle-wrapper.properties
#Thu Apr 06 06:38:18 BST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
非常感谢任何帮助。
由于
更新
local.properties
ndk.dir=C\:\\AndroidEclipse\\android-ndk-r10e
sdk.dir=C\:\\AndroidEclipse\\SDK
此行失败 def ndkDir = project.plugins.findPlugin(' com.android.application')。getNdkFolder()
答案 0 :(得分:1)
改为使用plugins.getPlugin('com.android.application').sdkHandler.ndkFolder
或android.ndkDirectory
。