Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle project sync failing after Google announced the new sdk versioning system

I am getting the following error:

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

Updated: I am able to build using com.google.gms:google-services:3.3.0 when data binding is disabled, but this is not a solution for someone that requires data binding to be enabled.

After Google announced the new sdk versioning system (link), I did the following steps:

  1. I updated the gradle files as directed to include the gms and firebase version numbers separately. Updated the apply plugin line, updated the classpath. I am still getting the error and dont know the reason.

  2. Below are relevant gradle files:

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 (Module:app)

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

Firebase dependencies:

//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 and other dependencies

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" 
  1. I have pasted the error log on pastebin from android studio 3.1.2 here.

Any help is appreciated!

like image 242
kash Avatar asked May 04 '18 02:05

kash


People also ask

How to Gradle sync in Android Studio?

Android Studio should automatically sync the project with Gradle when you robotify your app (ie make it compatible with Pepper's tablet). If it does not, then choose menu File > Sync project with Gradle Files or use the elephant icon Sync project from the menu bar to sync your project files manually.

Why is my Gradle sync failing?

In some cases when your Gradle files are deleted or corrupted you will not be able to download new Gradle files in android studio. In this case, we have to delete the Gradle files which are present already and then again sync your project to download our Gradle files again.

What is Android studio gradle?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.


1 Answers

managed to build against Play Services & Firebase 15.0.0 with data-binding enabled ...my dependencies now look about alike this and it builds again, without any Cannot change dependencies of configuration complaints:

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"     } } 

one has to reference all the libraries individually. just referencing com.google.android.gms:play‐services and/or com.google.firebase:firebase-core does not work anymore since 15.0.0.

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' 

also had to edit the Manifest.xml to fix the support library:

<application>      <meta-data         android:name="android.support.VERSION"         android:value="27.1.1"         tools:replace="android:value"/>  </application 
like image 117
Martin Zeitler Avatar answered Sep 23 '22 06:09

Martin Zeitler