Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Lebogang95 opened this issue Jan 29, 2019 · 95 comments
Assignees
Labels
p: tooling Affects the flutter_plugin_tools package package flutter/packages repository. See also p: labels. t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@Lebogang95
Copy link

Lebogang95 commented Jan 29, 2019

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
@Lebogang95
Copy link
Author

Lebogang95 commented Jan 29, 2019

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
}

@zoechi zoechi added tool Affects the "flutter" command-line tool. See also t: labels. plugin p: tooling Affects the flutter_plugin_tools package t: gradle "flutter build" and "flutter run" on Android labels Jan 30, 2019
@zoechi zoechi added this to the Goals milestone Jan 30, 2019
@Hixie
Copy link
Contributor

Hixie commented Feb 8, 2019

cc @amirh @mklim

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

@Hixie
Copy link
Contributor

Hixie commented Feb 8, 2019

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

@mklim mklim self-assigned this Feb 8, 2019
@mklim
Copy link
Contributor

mklim commented Feb 8, 2019

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

@mklim
Copy link
Contributor

mklim commented Feb 14, 2019

@Atominac found a reproducible case in #27679.

Steps to Reproduce

  flutter_local_notifications:
  firebase_core:
  firebase_messaging:

@czronaldo11
Copy link

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

@Boxerbuzz
Copy link

Still does not work after all the suggestions

@david-shortman
Copy link

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)

@prkhrv
Copy link

prkhrv commented Mar 4, 2019

@david-mccoy Thanks ! It worked for me!

@Boxerbuzz
Copy link

Boxerbuzz commented Mar 4, 2019 via email

@donjordano
Copy link

@david-mccoy great solution works for me! Thanks!

@RohanGautam
Copy link

@david-mccoy great answer. Annoying androidX issues have been bothering me lately and this worked for me

@aidooyaw1992
Copy link

this worked for me too

@GabrielMoreyra
Copy link

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)

Worked for me after changing also the Kotlin version (I have Kotlin support on my project) to 1.3.0 (I had 1.2.71)

@zzpmaster
Copy link

If gradle upgrade from 3.2.1 to 3.3.1, I found a problem that the android:label in androidmanifest.xml will not take effect after modified and meta-data will not take effect. @david-mccoy. Have you found this problem?

@david-shortman
Copy link

If gradle upgrade from 3.2.1 to 3.3.1, I found a problem that the android:label in androidmanifest.xml will not take effect after modified and meta-data will not take effect. @david-mccoy. Have you found this problem?

Sorry, I have not dealt with this problem

@sunojvijayan
Copy link

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)

Worked for me. Thanks.

@LinusU
Copy link

LinusU commented Mar 27, 2019

Bumping com.android.tools.build:gradle to 3.3.2 solved this issue for me as well.

Since this is a file that was generated by flutter create, is it flutters responsibility to keep it up to date, or me as a developer? 🤔

@lhcdims
Copy link

lhcdims commented Mar 28, 2019

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.

@sedhha
Copy link

sedhha commented Jan 12, 2020

Do let me know if you face problems locating any folder

Thanks @sedhha but nothing worked..
image
got same error. am I doing something wrong??

Can you show me the exact error?

It is the one in the prev comment I made ..

Hi @bdairy

I was having the same issue.
Please ensure the following things. I still see in your updated version statement:

classpath 'com.android.tools.build:gradle:3.5.0'
which should be 3.3.1

Also have you set minimum sdk version to 21?
Further I hope you have added this set of lines in gradle.properties:

android.useAndroidX = true
android.enableJetifier = true

Also you have changed kotlin version to 1.3.50 but it should be 1.3.0

@bdairy
Copy link

bdairy commented Jan 12, 2020

Do let me know if you face problems locating any folder

Thanks @sedhha but nothing worked..
image
got same error. am I doing something wrong??

Can you show me the exact error?

It is the one in the prev comment I made ..

Hi @bdairy

I was having the same issue.
Please ensure the following things. I still see in your updated version statement:

classpath 'com.android.tools.build:gradle:3.5.0'
which should be 3.3.1

Also have you set minimum sdk version to 21?
Further I hope you have added this set of lines in gradle.properties:

android.useAndroidX = true
android.enableJetifier = true

Also you have changed kotlin version to 1.3.50 but it should be 1.3.0

@sedhha my friend,, All what you've mentioned caused the same problem,,
image

the main issue is that Kotlin version update is not affecting the build...
as you can see my kotlin version is set to ext.kotlin_version = '1.3.0' . but the error says it is org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71

Now if any one has a solution for that please help I am really Stuck without any clarification of the issue...

@bdairy
Copy link

bdairy commented Jan 14, 2020

@blasten any update on this issue>? is there any hot fix? anything . I can do,, it has been more than 6 days,, please guys

@bdairy
Copy link

bdairy commented Jan 19, 2020

Just for the reference the problem was with a plugin that is called flutter_launch.. which no one notice in the error including me because the package name also miss leading,, anyway... I had to go the plugin and update the Kotlin version over there to fix the issue,, Thanks for the help everybody.

@blasten
Copy link

blasten commented Jan 23, 2020

@bdairy sorry for not replying earlier. The problem is in the flutter_launch plugin https://pub.dev/packages/flutter_launch. Which version of this plugin are you using? I saw the version was updated in Jun 2019: thyagoluciano/flutter_launch_whatsapp@d29f635

@escamoteur
Copy link
Contributor

@csells How will this be handled in future? I ran today into this after upgrading flutter and my plugins. At least we should find better error messages that tells the user what to do OR even better make flutter doctor to be able to fix such things

@blasten
Copy link

blasten commented Feb 20, 2020

The resolution of this problem involves finding plugin versions that satisfy the version constraints of each supported platform. When pub resolves a dependency, it doesn’t have knowledge of platform dependencies such as the Kotlin version used in a plugin.

That said, error messages can be improved.

We can highlight the specific plugin that is having issues. Currently, you get a Gradle error, which refers to a plugin as project.

@Gunkev
Copy link

Gunkev commented Feb 21, 2020

hello guy 1 actually have a problem "sync project with gradles file". it's disabled and how can i enable and show it in the android menu
Screenshot from 2020-02-21 13-34-40
?

@jonahwilliams jonahwilliams moved this from Awaiting triage to Engineer reviewed in Tools - Gradle review Mar 18, 2020
@BasemSaabneh
Copy link

follow these steps
step #1
$ flutter clean
$ flutter pub cache repair

step #2
in appRoot -> android -> build.gradle

  • set ext.kotlin_version = '1.3.50' or later versions
  • in dependencies set gradle version to 3.6.1 or later version
    classpath 'com.android.tools.build:gradle:3.6.1'
  • in subprojects add
    project.configurations.all {
    resolutionStrategy.eachDependency { details ->
    if (details.requested.group == 'androidx.core' &&
    !details.requested.name.contains('androidx')) {
    details.useVersion "1.0.1"
    }
    }
    }

step #3
in adnroid -> gradle -> wrapper -> gradle-wrapper.properties
set gradle to gradle-5.6.4-all.zip or later versions
distributionUrl=https://services.gradle.org/distributions/gradle-5.6.4-all.zip

step #4
$flutter clean

step #5
$flutter run

@blasten
Copy link

blasten commented Apr 10, 2020

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.

@maoyujiao
Copy link

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

@4tKnight
Copy link

4tKnight commented May 8, 2020

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

@Yuliang-Lee
Copy link

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

@Shivam-Shrivastav
Copy link

One of the Best Github Issue Discussion I have ever seen

@ShamshadSani
Copy link

#27254 (comment)
solved my isssue

@Bryanx
Copy link

Bryanx commented Aug 24, 2020

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

@joelbrostrom
Copy link

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?

@z234009184
Copy link

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!

@m-jabrane
Copy link

m-jabrane commented Jan 8, 2021

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

@theblueskies
Copy link

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'

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: tooling Affects the flutter_plugin_tools package package flutter/packages repository. See also p: labels. t: gradle "flutter build" and "flutter run" on Android tool Affects the "flutter" command-line tool. See also t: labels.
Projects
Tools - Gradle review
  
Engineer reviewed
Development

No branches or pull requests