Gradle sync失败:未找到Gradle DSL方法:' compile()',请参阅IDE日志以获取更多详细信息(帮助|显示日志)

时间:2016-03-01 16:50:05

标签: java android

我目前正在尝试学习如何使用Google服务apk,并尝试了一个名为 Buttonclicker 的示例,在那里我可以学习如何使用他们的多人apk。

然而,在按照所有说明操作后,我收到了错误

Gradle sync failed: Gradle DSL method not found: 'compile()'
            Consult IDE log for more details (Help | Show Log)

我尝试过查看类似的stackoverflow页面,但我似乎找不到任何解决方案。

我怀疑这与gradle有关,但我不确定我哪里出错了

这是在我生成了我的apk之后发生的,然后我开始尝试完成签名,然后在完成所有必需的步骤后将构建类型设置为释放。

Gradle file

Gradle文件代码

buildscript {
repositories {
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.1'
}
}

allprojects {
repositories {
    jcenter()
}

ext {
    android_compile_version = 23
    android_version = '23.0.1'
    android_min_sdk_version = 9

    appcompat_library_version = '23.0.1'
    support_library_version = '23.0.1'
    gms_library_version = '8.1.0'
}
}

Base Game Util代码:

apply plugin: 'com.android.library'


buildscript {
repositories {
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.1'
}
}

dependencies {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('appcompat_library_version')) {
    ext.appcompat_library_version = '20.0.+'
}
if (!project.hasProperty('support_library_version')) {
    ext.support_library_version = '20.0.+'
}
if (!project.hasProperty('gms_library_version')) {
    ext.gms_library_version = '8.1.0'
}

compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile "com.google.android.gms:play-services-games:${gms_library_version}"
compile "com.google.android.gms:play-services-plus:${gms_library_version}"
}

android {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_compile_version')) {
    ext.android_compile_version = 23
}
if (!project.hasProperty('android_version')) {
    ext.android_version = '23'
}

compileSdkVersion android_compile_version
buildToolsVersion android_version
}

按钮点击代码

apply plugin: 'com.android.application'

android {
signingConfigs {
    config {
        keyAlias 'ryan1k'
        keyPassword 'ryan11'
        storeFile file('C:/Users/Nayr/Desktop/ryan1.jks')
        storePassword 'ryan11'
    }
}
compileSdkVersion android_compile_version
buildToolsVersion android_version
defaultConfig {
    minSdkVersion android_min_sdk_version
    targetSdkVersion android_compile_version
    versionCode 1
    versionName "1.0"
}
lintOptions {
    abortOnError false
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),      'proguard-rules.txt'
        signingConfig signingConfigs.config
    }
}
}

dependencies {
compile "com.android.support:appcompat-v7:${appcompat_library_version}" compile "com.android.support:support-v4:${support_library_version}" compile project(':libraries:BaseGameUtils')
}

buildscript {
repositories {
    jcenter()
}
}

0 个答案:

没有答案