本文介绍了将Google Play服务升级到11.0.0版本后出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题。将Google Play服务库从版本10.2.6上传到版本11.0.0后,当我尝试编译时,出现以下错误:

我访问了错误中提到的链接以及google-服务插件似乎是3.1.0,即我使用的版本,并且我已经将所有播放服务库升级到11.0.0版本。我可以使用11.0.0版本的GMS来编译我的代码吗?



这是我的build.gradle文件(模块范围):

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

android {

compileSdkVersion 25
buildToolsVersion25.0.2
defaultConfig {
applicationIdcom.example.app
minSdkVersion 15
targetSdkVersion 25
versionCode 23
versionName0.7.3.2
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
manifestPlaceholders = [onesignal_app_id:12345678-1234-1234-1234-123456789 ,
//从仪表板拉出的项目编号,本地值被忽略。
onesignal_google_project_number:REMOTE]
multiDexEnabled true
}
buildTypes {

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

productFlavors {
prontopro {
applicationIdcom。 example.app
buildConfigFieldboolean,TEST_ENVIRONMENT,false
}

prontoproTest {
applicationIdcom.example.app
buildConfigFieldboolean,TEST_ENVIRONMENT,true
}
}

dataBinding {
enabled = true
}
}

依赖关系{
编译fileTree(包括:['* .jar'],dir:'libs')
compile'c​​om.android.support:multidex:1.0.1 '
compile'c​​om.android.support:appcompat-v7:25。 3.1'
compile'c​​om.android.support:design:25.3.1'
compile'c​​om.google.android.gms:play-services-places:11.0.0'
compile' com.google.android.gms:play-services-location:11.0.0'
compile'org.parceler:parceler-api:1.1.6'
annotationProcessor'org.parceler:parceler:1.1。 6'
annotationProcessor'com.android.databinding:compiler:2.2.2'
compile'c​​om.viewpagerindicator:library:2.4.1'
compile'c​​om.squareup.retrofit2:retrofit: 2.1.0'
compile'c​​om.squareup.retrofit2:converter-gson:2.1.0'
compile'c​​om.squareup.okhttp3:logging-interceptor:3.4.2'
compile' com.google.code.gson:gson:2.7'
compile'c​​om.github.bumptech.glide:glide:3.7.0'
compile'c​​om.github.chrisbanes:PhotoView:1.2.6'
编译'de.hdodenhof:circleimageview:2.1.0'
编译'com.facebook.android:facebook-android-sdk:[4,5)'
编译'io.realm:和roid-adapters:2.0.0'
compile'c​​om.google.firebase:firebase-crash:10.2.6'
//反应图书馆
编译'io.reactivex:rxandroid:1.2。 1'
compile'io.reactivex:rxjava:1.2.3'
compile'c​​om.jakewharton.rxbinding:rxbinding:1.0.0'
compile'c​​om.jakewharton.rxbinding:rxbinding- support-v4:1.0.0'
compile'c​​om.jakewharton.rxbinding:rxbinding-appcompat-v7:1.0.0'
compile'c​​om.jakewharton.rxbinding:rxbinding-design:1.0.0'
compile'c​​om.jakewharton.rxbinding:rxbinding-recyclerview -v7:1.0.0'
compile'c​​om.tbruyelle.rxpermissions:rxpermissions:0.8.2@aar'
compile'c​​om。 squareup.retrofit2:adapter-rxjava:2.1.0'
compile'c​​om.github.pwittchen:reactivenetwork:0.8.0'
compile'c​​om.hwangjr.rxbus:rxbus:1.0.5'
编译'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
//测试
androidTestCompile('com.android.support.test。 espresso:espresso-core:2.2.2',{
exclude group:'com.android.support',module:'support-annotations'
})
testCompile'junit:junit: 4.12'
testCompile'org.mockito:mockito-core:2.6.3'
// onesignal
compile'c​​om.onesignal:OneSignal:3.4.4@aar'
compile com.mixpanel.android:mixpanel-android:5.1.0
compile'c​​om.google.android.gms:play-services-gcm:11.0.0'
}
apply plugin :'com.google.gms.google-services'

最后,这是我的build.gradle文件(

  //顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。 
$ b buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle: 2.3.2'
classpath'io.realm:realm-gradle-plugin:3.1.4'
classpath'com.google.gms:google-services:3.1.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}

allprojects {
存储库{
maven {url http://dl.bintray.com/populov/maven}
maven {urlhttps://jitpack.io}
mavenCentral()
jcenter()
}
}

任务清理(类型:删除){
删除rootProject.buildDir
}


解决方案

您应该删除 apply插件:'com.google.gms.google-services'



因为 apply plugin:'com.android.application'已经有相同的包。



这是冲突发生的地方。

更新:



使用Play服务版本 11.0.1


I have a strange issue. After uploading Google Play Services library from version 10.2.6 to version 11.0.0, when i try to compile I get this error:

I visited the link mentioned in the error and the last version of the google-services plugin seems to be 3.1.0, ie the version i am using, and i have already upgraded all the play services libraries to 11.0.0 version. What can I do to compile my code with 11.0.0 version of GMS?

Here's my build.gradle file (module scope):

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

android {

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 23
        versionName "0.7.3.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        manifestPlaceholders = [onesignal_app_id               : "12345678-1234-1234-1234-123456789",
                            // Project number pulled from dashboard, local value is ignored.
                            onesignal_google_project_number: "REMOTE"]
        multiDexEnabled true
    }
    buildTypes {

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

    productFlavors {
        prontopro {
            applicationId "com.example.app"
            buildConfigField "boolean", "TEST_ENVIRONMENT", "false"
        }

        prontoproTest {
            applicationId "com.example.app"
            buildConfigField "boolean", "TEST_ENVIRONMENT", "true"
        }
    }

    dataBinding {
        enabled = true
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.google.android.gms:play-services-places:11.0.0'
    compile 'com.google.android.gms:play-services-location:11.0.0'
    compile 'org.parceler:parceler-api:1.1.6'
    annotationProcessor 'org.parceler:parceler:1.1.6'
    annotationProcessor 'com.android.databinding:compiler:2.2.2'
    compile 'com.viewpagerindicator:library:2.4.1'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.2'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.chrisbanes:PhotoView:1.2.6'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'io.realm:android-adapters:2.0.0'
    compile 'com.google.firebase:firebase-crash:10.2.6'
    //reactive libraries
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.2.3'
    compile 'com.jakewharton.rxbinding:rxbinding:1.0.0'
    compile 'com.jakewharton.rxbinding:rxbinding-support-v4:1.0.0'
    compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:1.0.0'
    compile 'com.jakewharton.rxbinding:rxbinding-design:1.0.0'
    compile 'com.jakewharton.rxbinding:rxbinding-recyclerview-v7:1.0.0'
    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.8.2@aar'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.github.pwittchen:reactivenetwork:0.8.0'
    compile 'com.hwangjr.rxbus:rxbus:1.0.5'
    compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2'
    //testing
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:2.6.3'
    //onesignal
    compile 'com.onesignal:OneSignal:3.4.4@aar'
    compile "com.mixpanel.android:mixpanel-android:5.1.0"
    compile 'com.google.android.gms:play-services-gcm:11.0.0'
}
apply plugin: 'com.google.gms.google-services'

And finally here's my build.gradle file (app scope):

// 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.2'
        classpath 'io.realm:realm-gradle-plugin:3.1.4'
        classpath 'com.google.gms:google-services:3.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        maven { url "https://jitpack.io" }
        mavenCentral()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
解决方案

You should delete the line apply plugin: 'com.google.gms.google-services'

Because apply plugin: 'com.android.application' already has same package.

That's where the conflict arises.

UPDATE:

Use Play services version 11.0.1

这篇关于将Google Play服务升级到11.0.0版本后出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 11:47