安卓 – Gradle项目同步失败后谷歌宣布新的SD版本系统

我收到以下错误

Cannot change dependencies of configuration ':app:api' after it has been included in dependency resolution.

更新:
我可以在禁用数据绑定时使用com.google.gms:google-services:3.3.0进行构建,但对于需要启用数据绑定的人来说,这不是一个解决方案.

谷歌宣布新的sdk版本控制系统(link)后,我做了以下步骤:

>我按指示更新了gradle文件,分别包含gms和firebase版本号.更新了apply插件行,更新了类路径.我仍然得到错误,不知道原因.
>以下是相关的gradle文件

build.gradle(main):

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/rvalerio/maven' }
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:3.3.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'io.realm:realm-gradle-plugin:4.3.3'
        classpath 'io.fabric.tools:gradle:1.25.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url 'https://maven.google.com' }
    }
}

build.gradle(模块:app)

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

Firebase依赖项:

//Firebase Dependencies
implementation "com.google.firebase:firebase-messaging:15.0.2"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-config:15.0.2"
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
    transitive = true
}

GMS和其他依赖项

implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:support-v13:27.1.1"
implementation "com.android.support.constraint:constraint-layout:1.1.0"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-vision:15.0.1"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"

>我已经从android studio 3.1.2 here粘贴了pastebin上的错误日志.

任何帮助表示赞赏!

解决方法:

设法打造Play Services& Firebase 15.0.0启用了数据绑定…我的依赖关系现在看起来很相似,它再次构建,没有任何不能更改配置投诉的依赖关系:

buildscript {

    dependencies {

        classpath "com.android.tools.build:gradle:3.1.2"

        // do not update, because 3.3.1 appears broken
        // classpath "com.google.gms:google-services:3.2.1"

        // meanwhile, there is version 4.0.2 available
        classpath "com.google.gms:google-services:4.0.2"
    }
}

一个人必须单独引用所有库.仅引用com.google.android.gms:play-services和/或com.google.firebase:自15.0.0以来,firebase-core不再有效.

android {

    dependencies {

        // Play Services 15.0.0
        implementation "com.google.android.gms:play-services-base:15.0.1"
        implementation "com.google.android.gms:play-services-auth:15.0.1"
        implementation "com.google.android.gms:play-services-identity:15.0.1"

        // Firebase 15.0.0
        implementation "com.google.firebase:firebase-core:15.0.2"
        implementation "com.google.firebase:firebase-database:15.0.1"
        implementation "com.google.firebase:firebase-firestore:16.0.0"
        implementation "com.google.firebase:firebase-storage:15.0.2"
        implementation "com.google.firebase:firebase-crash:15.0.2"
        implementation "com.google.firebase:firebase-auth:15.1.0"
        implementation "com.google.firebase:firebase-messaging:15.0.2"
        implementation "com.google.firebase:firebase-config:15.0.2"
        implementation "com.google.firebase:firebase-invites:15.0.1"
        implementation "com.google.firebase:firebase-ads:15.0.1"
        implementation "com.google.firebase:firebase-appindexing:15.0.1"
        implementation "com.google.firebase:firebase-perf:15.2.0"
        implementation "com.google.firebase:firebase-functions:15.0.0"
    }
}

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

还必须编辑Manifest.xml来修复支持库:

<application>

    <Meta-data
        android:name="android.support.VERSION"
        android:value="27.1.1"
        tools:replace="android:value"/>

</application

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...