Skip to content

Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution #27254

Closed

Description

@Lebogang95

I know what this problem means but I don't know how to come up with a solution to this exact one. I've provided code which is a fix to a similar problem I had with the android support libraries.

subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex') ) {
                    details.useVersion "27.1.1"
                }
            }
        }
    }

Here is some more information on the issue

Launching lib\main.dart on TA 1024 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
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:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution

* 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 6s
Finished with error: Gradle task assembleDebug failed with exit code 1

Activity

  1. Lebogang95 commented on Jan 29, 2019

    @Lebogang95
    Author

    Okay so I managed to fix the error by adding this snippet of code like so

    subprojects {
            project.configurations.all {
                resolutionStrategy.eachDependency { details ->
                    if (details.requested.group == 'com.android.support'
                            && !details.requested.name.contains('multidex') ) {
                        details.useVersion "27.1.1"
                    }
                    if (details.requested.group == 'androidx.core'
                            && !details.requested.name.contains('androidx') ) {
                        details.useVersion "1.0.1"
                    }
                }
            }
        }

    Paste this into your build.gradle under build script like so.

    buildscript {
        ext.kotlin_version = '1.2.51'
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.2.0'
        }
    
        subprojects {
            project.configurations.all {
                resolutionStrategy.eachDependency { details ->
                    if (details.requested.group == 'com.android.support'
                            && !details.requested.name.contains('multidex') ) {
                        details.useVersion "27.1.1"
                    }
    
                    if (details.requested.group == 'androidx.core'
                            && !details.requested.name.contains('androidx') ) {
                        details.useVersion "1.0.1"
                    }
                }
            }
        }
    
    }
    
    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
    }
  2. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    p: toolingAffects the flutter_plugin_tools package
    t: gradle"flutter build" and "flutter run" on Android
    on Jan 30, 2019
  3. added this to the milestone on Jan 30, 2019
  4. Hixie commented on Feb 8, 2019

    @Hixie
    Contributor

    cc @amirh @mklim

    After upgrading the compileSdkVersion from 27 to 28 on my app, I got this error.

  5. Hixie commented on Feb 8, 2019

    @Hixie
    Contributor

    I pasted the following dark magic into .../android/build.gradle (not .../android/app/build.grade) and that made the problem go away:

    subprojects {
        project.configurations.all {
    	resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'androidx.core' &&
    	       !details.requested.name.contains('androidx')) {
    		details.useVersion "1.0.1"
                }
    	}
        }    
    }
  6. self-assigned this
    on Feb 8, 2019
  7. mklim commented on Feb 8, 2019

    @mklim
    Contributor

    I'm having trouble reproducing this so far. If anyone has sharable code that triggers this error it would be really helpful for debugging.

  8. mklim commented on Feb 14, 2019

    @mklim
    Contributor

    @Atominac found a reproducible case in #27679.

    Steps to Reproduce

      flutter_local_notifications:
      firebase_core:
      firebase_messaging:
  9. czronaldo11 commented on Feb 19, 2019

    @czronaldo11

    I use Hixie's function.and the problem go away

  10. Boxerbuzz commented on Feb 28, 2019

    @Boxerbuzz

    Still does not work after all the suggestions

  11. david-shortman commented on Mar 1, 2019

    @david-shortman

    Still does not work after all the suggestions

    No joke, I recently had the same problem (and I was getting many complaints about various dependencies that were AndroidX, with -rc01 version endings), and various solutions for forcing a resolution strategy were not working.

    I solved it by upgrading my gradle dependency in the android/build.gradle file: classpath 'com.android.tools.build:gradle:3.3.1' (I was previously on version 3.2.1)

  12. 83 remaining items

  13. blasten commented on Apr 10, 2020

    @blasten

    I'm closing this bug as the original issue was caused by combining AndroidX and support dependencies. The AndroidX migration guide walks through the steps to avoid this problem: https://flutter.dev/docs/development/androidx-migration.

  14. maoyujiao commented on Apr 24, 2020

    @maoyujiao

    If you have kotlin support in your flutter app, to solve this problem, you need to change 2 values in android/build.gradle:

    1. change kotlin_version from 1.2.71 to 1.3.0
    2. change gradle version from 3.2.1 to 3.3.2

    as at 2019/03/28.

    thanks,for this ,it works for me

  15. 4tKnight commented on May 8, 2020

    @4tKnight

    I pasted the following dark magic into .../android/build.gradle (not .../android/app/build.grade) and that made the problem go away:

    subprojects {
        project.configurations.all {
    	resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'androidx.core' &&
    	       !details.requested.name.contains('androidx')) {
    		details.useVersion "1.0.1"
                }
    	}
        }    
    }

    works for me perfectly

  16. Yuliang-Lee commented on Jun 3, 2020

    @Yuliang-Lee

    If you have kotlin support in your flutter app, to solve this problem, you need to change 2 values in android/build.gradle:

    1. change kotlin_version from 1.2.71 to 1.3.0
    2. change gradle version from 3.2.1 to 3.3.2

    as at 2019/03/28.

    work for me

  17. Shivam-Shrivastav commented on Jul 28, 2020

    @Shivam-Shrivastav

    One of the Best Github Issue Discussion I have ever seen

  18. ShamshadSani commented on Aug 7, 2020

    @ShamshadSani

    #27254 (comment)
    solved my isssue

  19. Bryanx commented on Aug 24, 2020

    @Bryanx

    Running into this issue again after updating cloud_firestore from 0.13.5 to 0.14.0+2.

  20. joelbrostrom commented on Sep 24, 2020

    @joelbrostrom

    Worked for me as well.

    If you have kotlin support in your flutter app, to solve this problem, you need to change 2 values in android/build.gradle:

    change kotlin_version from 1.2.71 to 1.3.0
    change gradle version from 3.2.1 to 3.3.2
    as at 2019/03/28.

    This is what it looks like in the build.gradle file:

    buildscript {
        ext.kotlin_version = '1.3.0'
        repositories {
            google()
            jcenter()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.2'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    

    Is there a way to let flutter do this change when a package that relies on it is being updated/added?

  21. z234009184 commented on Oct 13, 2020

    @z234009184

    Still does not work after all the suggestions

    No joke, I recently had the same problem (and I was getting many complaints about various dependencies that were AndroidX, with -rc01 version endings), and various solutions for forcing a resolution strategy were not working.

    I solved it by upgrading my gradle dependency in the android/build.gradle file: classpath 'com.android.tools.build:gradle:3.3.1' (I was previously on version 3.2.1)

    Thanks! It worked for me!

  22. m-jabrane commented on Jan 8, 2021

    @m-jabrane

    Running into this issue again after updating cloud_firestore from 0.13.5 to 0.14.0+2.

    @Bryanx I have the same issue with cloud_firestore: ^0.14.3+1, have you found a solution or a workaround ?

    Update:
    756990464

  23. theblueskies commented on Jun 21, 2021

    @theblueskies

    Adding this line to upgrade android tools in the dependency section in android/build.gradle solved it for me:
    classpath 'com.android.tools.build:gradle:3.5.1'

  24. github-actions commented on Jul 31, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  25. locked as resolved and limited conversation to collaborators on Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p: toolingAffects the flutter_plugin_tools packagepackageflutter/packages repository. See also p: labels.t: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions