Eoin Molloy
Eoin Molloy

Reputation: 173

How to fix 'Dependency failing' when building Flutter application on Android

I am trying to use Google Sign in with my Flutter application. However, I am unable to build the application due to some issues with dependencies. I have updated all of my dependencies to the latest version but to no avail. How do I resolve these dependencies so I can build the application?

This is for a simple flutter application using google sign in running on a connected OnePlus 6 android phone.

I have tried updating my dependencies to the latest version as well as changing the code to match the latest version of the google_sign_in dependency found here: https://pub.dartlang.org/packages/google_sign_in

I also tried adding firebase_core to the list of dependencies as the error message said that the app relied on firebase_core. This did nothing to change the error message.

Project 'pubspec.yaml' dependencies

dependencies:
  flutter:
    sdk: flutter

  duration: ^2.0.0
  firebase_core: ^0.3.2
  cloud_firestore: ^0.9.11
  firebase_auth: ^0.8.4
  google_sign_in: ^4.0.1+3
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter  

Project Level build.gradle (android/build.gradle):

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        // Google Services class path
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

App Level build.gradle (android/app/build.gradle):

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.recipe_app"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

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

The output of 'flutter run':

Launching lib/main.dart on ONEPLUS A6003 in debug mode...
Initializing gradle...                                              1.0s
Resolving dependencies...                                           4.0s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:checkDebugClasspath' property 'compileClasspath' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0.
  1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-stats:15.0.1 -> com.google.android.gms:play-services-basement@[
  15.0.1], but play-services-basement version was 16.1.0.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends on project 'cloud_firestore' which depends onto com.google.firebase:[email protected]
  -- Project 'app' depends onto com.google.firebase:[email protected]
  -- Project 'app' depends on project 'firebase_auth' which depends onto com.google.firebase:[email protected]
  -- Project 'app' depends on project 'google_sign_in' which depends onto com.google.android.gms:[email protected]

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
  uild.gradle file.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                         2.9s
Gradle task assembleDebug failed with exit code 1

I expected the application to build successfully so I could test if Google Sign in worked. However, the application does not build successfully and I am at a loss as to what to do.

Upvotes: 2

Views: 5206

Answers (1)

Eoin Molloy
Eoin Molloy

Reputation: 173

I attempted to recompile using verbose mode and was informed about AndroidX being the cause.

I followed this link and downgraded all of the dependencies to the versions before the AndroidX migration as listed in the article. This fixed the issue.

Upvotes: 1

Related Questions