错误:修复版本冲突(google-services插件)

时间:2017-08-04 07:42:28

标签: android firebase google-play-services firebase-cloud-messaging

根据this SO帖子,我知道存在版本冲突,但在Google发布新版本后问题仍然存在。

  

错误:任务':app:processDebugGoogleServices'执行失败。   请修改版本冲突,方法是更新google-services插件的版本(https://bintray.com/android/android-tools/com.google.gms.google-services/提供有关最新版本的信息)或将com.google.android.gms版本更新为10.0.1。

我的 build.gradle(模块:应用)

....
dependencies {
   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:appcompat-v7:26.+'
   compile 'com.android.support.constraint:constraint-layout:1.0.2'
   testCompile 'junit:junit:4.12'
   compile 'com.google.firebase:firebase-messaging:10.0.1'
   compile 'com.google.android.gms:play-services-maps:11.0.4'
   compile 'com.google.android.gms:play-services-location:11.0.4'
}

apply plugin: 'com.google.gms.google-services'


现在需要进行哪些更改?

14 个答案:

答案 0 :(得分:54)

我认为你改变了

compile 'com.google.firebase:firebase-messaging:11.0.4'

答案 1 :(得分:36)

时会抛出相同的错误
apply plugin: 'com.google.gms.google-services'

未添加到模块build.gradle文件的底部。

答案 2 :(得分:30)

您必须只为所有3个库使用一个版本

compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'

或者仅对3个库使用10.0.1

答案 3 :(得分:22)

请更改您必须更改build.gradlegoogle-services路径的依赖关系类路径的项目级build.gradle文件。

buildscript {

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

答案 4 :(得分:19)

Google Play服务要求其所有依赖项具有相同的版本。但是如果你看看你的依赖关系:

11.0.4

有一个版本不同。

可以通过将版本更改为(在本例中)10.0.1来解决。

这适用于Firebase和Google Play服务 - 两者都必须具有相互匹配的匹配版本。如果Firebase依赖关系为11.0.4且Google Play服务依赖关系为x,则会出现相同的错误。

请注意,在某些情况下,可能有一个库具有不同版本的库(例如库play-services-games:10.0.1使用11.0.4,而您在应用中使用com.google.gms:google-services:4.1.0依赖关系)

修改

此答案不包括版本个别的较新版本。更新import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationManager; import java.util.List; public class MyTasklet implements Tasklet { @Override public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception { TransactionStatus transactionStatus = getTransactionSynchronizationsAndClear(); try { /** * execute my code */ } finally { initTransactionSyncs(transactionStatus); } return RepeatStatus.FINISHED; } private void initTransactionSyncs(TransactionStatus status) { try { TransactionSynchronizationManager.initSynchronization(); TransactionSynchronizationManager.setCurrentTransactionName(status.getName()); TransactionSynchronizationManager.setActualTransactionActive(status.isActive()); TransactionSynchronizationManager.setCurrentTransactionReadOnly(status.isReadOnly()); TransactionSynchronizationManager.setCurrentTransactionIsolationLevel(status.getIsolationLevel()); for (TransactionSynchronization sync : GainsightCollectionUtils.nullSafeList(status.getSyncs())) { TransactionSynchronizationManager.registerSynchronization(sync); } } catch (Exception e) { e.printStackTrace(); } } private TransactionStatus getTransactionSynchronizationsAndClear() { try { TransactionStatus transactionStatus = new TransactionStatus(); transactionStatus.setSyncs(TransactionSynchronizationManager.getSynchronizations()); transactionStatus.setName(TransactionSynchronizationManager.getCurrentTransactionName()); transactionStatus.setReadOnly(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); transactionStatus.setIsolationLevel(TransactionSynchronizationManager.getCurrentTransactionIsolationLevel()); transactionStatus.setActive(TransactionSynchronizationManager.isActualTransactionActive()); TransactionSynchronizationManager.clear(); return transactionStatus; } catch (Exception e) { e.printStackTrace(); } return null; } private class TransactionStatus { private String name; private boolean readOnly; private boolean active; private Integer isolationLevel; private List<TransactionSynchronization> syncs; public String getName() { return name; } public void setName(String name) { this.name = name; } public boolean isReadOnly() { return readOnly; } public void setReadOnly(boolean readOnly) { this.readOnly = readOnly; } public boolean isActive() { return active; } public void setActive(boolean active) { this.active = active; } public Integer getIsolationLevel() { return isolationLevel; } public void setIsolationLevel(Integer isolationLevel) { this.isolationLevel = isolationLevel; } public List<TransactionSynchronization> getSyncs() { return syncs; } public void setSyncs(List<TransactionSynchronization> syncs) { this.syncs = syncs; } } } 并检查mvnrepository(或其他一些maven / gradle工件搜索工具)以查找最新版本。

答案 5 :(得分:5)

要正确安装fire base,所有版本的fire base compiles必须是相同的版本,所以

compile 'com.google.firebase:firebase-messaging:11.0.4' 
compile 'com.google.android.gms:play-services-maps:11.0.4' 
compile 'com.google.android.gms:play-services-location:11.0.4'

这是正确的方法。

答案 6 :(得分:5)

使用

com.android.tools.build:gradle:3.2.0

您必须使用:

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

这解决了我的问题

答案 7 :(得分:2)

最初,firebase数据库指向11.8.0。将所有相关的jar更改为11.0.4后,此问题在SDK级别得到解决。     编译'com.google.firebase:firebase-database:11.0.4'     编译'com.google.firebase:firebase-messaging:11.0.4'

答案 8 :(得分:1)

重要更新

  

与过去不同,Firebase和Play服务依赖都具有独立的版本。如果   您有版本冲突,则可以更新   com.google.gms:google-services。并开始定义独立版本。

步骤(1):更新com.google.gms:google-services

  

打开项目级别build.gradle,并将com.google.gms:google-services更新为版本4.1.0 MUST CHECK newer if available

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.1.0' //< update this 
    }
}

步骤(2):更新Firebase依赖项 Latest Versions

Firebase依赖版本可以是单独的。

com.google.firebase:firebase-core:16.0.3    //Analytics, check latest too
com.google.firebase:firebase-database:16.0.2    //Realtime Database, check latest too

步骤(3):更新Play服务依赖项 Latest Versions

播放服务版本也可以具有单独的版本。

com.google.android.gms:play-services-ads:17.1.2 //Ads, check latest too
com.google.android.gms:play-services-analytics:16.0.6   //Analytics, check latest too

仍然有问题吗? 您可以通过阅读 this answer 来检查哪个依赖项引起冲突。

答案 9 :(得分:1)

更新 Google服务和Firebase库为最新版本

google服务

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

firebase

 implementation 'com.google.firebase:firebase-database:19.0.0'

答案 10 :(得分:0)

正如消息所说: com.google.gms.google-services versions

复制上一版本的号码。我的不到3.3.1。 然后在项目的build.gradle put / change dependencies节点中:

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2' // as it was before             
    classpath 'com.google.gms:google-services:3.3.1' // <-- the version change                  
        }

然后我同步了项目并且错误发生了

答案 11 :(得分:0)

所有Google服务应该是相同的版本,请尝试 匹配 每个 版本

正确的是:

  implementation 'com.google.firebase:firebase-auth:11.6.0'
  implementation 'com.google.firebase:firebase-database:11.6.0'

不正确的配置是:

 implementation 'com.google.firebase:firebase-auth:11.6.0'
 implementation 'com.google.firebase:firebase-database:11.8.0'

答案 12 :(得分:0)

After All Working for 6 hours i got the solution...

Simple Just what ever the plugins you defined in the build.gradle file... for ex: google services plugins or firebase plugins or any third party plugins all the **version code** should be same..

Example: In my application i am using following plugins...

    // google services plugins
    implementation 'com.google.android.gms:play-services-analytics:10.0.1'
    implementation 'com.google.android.gms:play-services-gcm:10.0.1'
    implementation 'com.google.android.gms:play-services-base:11.6.1'
    implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0'

    //firebase plugin
    implementation 'com.google.firebase:firebase-ads:10.0.1'

    //Third Party plugin
    implementation 'com.google.android.gms:play-services-auth:16.0.0'

在上述插件的版本代码(例如:10.0.1、16.0.0、11.6.1)中,我遇到的是修复版本冲突(google-services插件)问题

Below for all plugins i have given single version code(11.6.0) and the issue is resovled...

 // google services plugins
    implementation 'com.google.android.gms:play-services-analytics:11.6.0'
    implementation 'com.google.android.gms:play-services-gcm:11.6.0'
    implementation 'com.google.android.gms:play-services-base:11.6.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0'

    //firebase plugin
    implementation 'com.google.firebase:firebase-ads:11.6.0'

    //Third Party plugin
    implementation 'com.google.android.gms:play-services-auth:11.6.0'


**Syn Gradle**...

Go to Build>>Rebuild Projcet...

Sure it will work....@Ambilpura

答案 13 :(得分:-2)

安装或更新Google Play服务。其次,请检查您的“com.google.gms:google-services:3.0.0”版本。检查,如果仍然不能正常升级到3.1.0