【问题标题】:Could not find method compile() for arguments [com.google.gms:google-services:3.1.1]找不到参数 [com.google.gms:google-services:3.1.1] 的方法 compile()
【发布时间】:2017-11-04 19:53:01
【问题描述】:

在尝试更新到最新的 Glide 时,我得到了更新新的谷歌服务的信息,我已经将它引入了 gradle 并且从这一刻起 nothink 工作。 我尝试过的:

1)我已经读过,当某些依赖项的版本与其他依赖项不同时,可能会发生此错误所以我尝试 //(临时删除)所有依赖项为了而不是一一“取消哈希”依赖项来解决问题一个,但它没有解决问题

2) 我尝试编译 com.google.gms:google-services:3.1.1/ 3.1.2/3.0.0/3.1.0 但这些都不起作用

3) 我尝试了 https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f 中的方法并强制编译为 true,但没有成功

我得到的错误

错误:(10, 0) 无法在 org.gradle.api.internal.artifacts.dsl 类型的对象上找到参数 [com.google.gms:google-services:3.1.1] 的方法 compile()。依赖项.DefaultDependencyHandler。 打开文件

如果有任何帮助,我将不胜感激!

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        jcenter()
        google()
    }
    dependencies {
        compile 'com.google.gms:google-services:3.1.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
       compile 'com.google.gms:google-services:3.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

       classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven {
            url "https://maven.google.com"
        }

    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

第二个 build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.lenovo.licz4"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support:support-v4:26.1.0'
    implementation "android.arch.lifecycle:extensions:1.0.0-rc1"
    implementation "android.arch.lifecycle:runtime:1.0.3"
    implementation 'com.google.firebase:firebase-storage:11.0.4'
    implementation 'com.google.firebase:firebase-auth:11.0.4'
    annotationProcessor "android.arch.lifecycle:compiler:1.0.0-rc1"
    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.0'

    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:preference-v14:26.1.0'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:preference-v7:26.1.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-core:11.4.2'
    compile 'com.github.bumptech.glide:glide:4.3.0'

   testCompile 'junit:junit:4.12'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

}




apply plugin: 'com.google.gms.google-services'
repositories {
    mavenCentral()
}
apply plugin: 'kotlin-android-extensions'

【问题讨论】:

    标签: android android-gradle-plugin google-play-services


    【解决方案1】:

    删除您的顶级文件中的这些行:

    compile 'com.google.gms:google-services:3.1.1'
    compile 'com.google.gms:google-services:3.1.0'
    

    添加

    classpath 'com.google.gms:google-services:3.1.0'
    

    【讨论】:

    • 非常感谢!为了使它工作,我必须添加两个类路径,但不要介意这个小缺点谢谢 classpath 'com.android.tools.build:gradle:3.0.0' classpath 'com.google.gms:google-services:3.1 .0'
    猜你喜欢
    • 2019-05-11
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 1970-01-01
    • 1970-01-01
    • 2019-05-11
    相关资源
    最近更新 更多