Flutter: 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

Created on 29 Jan 2019  ·  92Comments  ·  Source: flutter/flutter

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
first party tooling plugin gradle tool

Most helpful comment

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)

All 92 comments

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.

``` gradle
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
}
```

cc @amirh @mklim

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

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

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

@Atominac found a reproducible case in #27679.

Steps to Reproduce

  flutter_local_notifications:
  firebase_core:
  firebase_messaging:

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

Still does not work after all the suggestions

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)

@david-mccoy Thanks ! It worked for me!

Thankx worked for me

On Mon, Mar 4, 2019, 9:34 AM Prakhar Varshney notifications@github.com
wrote:

@david-mccoy https://github.com/david-mccoy Thanks ! It worked for me!


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/flutter/flutter/issues/27254#issuecomment-469163125,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AX2WfqRQkKG5VGc-8xt1c1vIQhwBzHBKks5vTNqOgaJpZM4aYzDb
.

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

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

this worked for me too

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)

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?

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

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.

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? 🤔

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.

happened to me, changing both kotlin and gradle worked

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)

Thank you!!!

This issue will be fixed by https://github.com/flutter/flutter/pull/35217

I have searched a lot about this and finally this helps me,
Try this:

1.Go to build.gradle under gradle folder and change the classpath dependancies to

buildscript {
     repositories {
          google()
           jcenter()
 }

 dependencies {
    classpath 'com.android.tools.build:gradle:**3.4.1**'
  }
}
  1. Go to android->gradle->wrapper->gradle-wrapper.properties and change the distribution URL to

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

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)

@david-mccoy Thanks, it works finally

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 mate. It works.

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
}

Saved my day, thank you :)

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)

Got it. Thank you!

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 ! It works for me

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

[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Microsoft Windows [Version 10.0.17763.678], locale tr-TR)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.37.1)
[√] Connected device (1 available)

I have searched a lot about this and finally this helps me,
Try this:

1.Go to build.gradle under gradle folder and change the classpath dependancies to

buildscript {
     repositories {
          google()
           jcenter()
 }

 dependencies {
    classpath 'com.android.tools.build:gradle:**3.4.1**'
  }
}
  1. Go to android->gradle->wrapper->gradle-wrapper.properties and change the distribution URL to
    distributionUrl=https\://services.gradle.org/distributions/**gradle-5.1.1-all.zip**
#

Upgrade Android Gradle Plugin and Gradle to the latest version can solve this problem. For Android Studio 3.5, modify these:
android/build.gradle

com.android.tools.build:gradle:3.5.0

android/gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
#

Of course, you should manually set the same version via DependencyResolution. So, the following resolution strategy can also be used to resolve the conflicts of dependency :
android/gradle.properties:

androidxCoreVersion=1.0.0
androidxLifecycleVersion=2.0.0
````
android/build.gradle: 
```groovy
subprojects {
    project.configurations.all {
        resolutionStrategy {
            force "androidx.core:core:${androidxCoreVersion}"
            force "androidx.lifecycle:lifecycle-common:${androidxLifecycleVersion}"
        }
    }
}

the previous error is solved thanks to @Lebogang95 but Im facing a new one with androidx.swiperefreshlayout and androidx.localbroadcastmanager:localbroadcastmanager and it keeps coming every time with a new Error.
One of the Errors reads:
Android dependency 'androidx.drawerlayout:drawerlayout' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution

any idea guyz?

Update Gradle solves to me.

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

classpath 'com.android.tools.build:gradle:3.5.0'

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 a lot ! u ve just saved my day

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)

Worked for me too. Thank you.

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.

It works. Thanks.

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.

It works. Thanks.

+1

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

Thanks for this!!! Been hours trying to figure things out.

I updated the project, migrated to androidx, and upgraded gradle, which I think would be better.

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)

Thanks it worked for me

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)

I' had wasted 2 days trying to find a solution, and only your advice saved me! Thanks a lot and be happy :)

No problem Bro :)

On Tue, Oct 1, 2019 at 11:30 PM Konstantin notifications@github.com wrote:

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)

I've wasted 2 days trying to find a solution, and only your advice saved
me! Thanks a lot and be happy :)


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/flutter/flutter/issues/27254?email_source=notifications&email_token=AM36K6XWUVIUJZBKV2YNN23QMQ5XHA5CNFSM4GTDGDN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEADWJEQ#issuecomment-537355410,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AM36K6RLHCLRE64Q3OKFO53QMQ5XHANCNFSM4GTDGDNQ
.

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
}

Thanks, buddy, you solved my big problem...

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)

Kotlin Version is V imp for it to work. Do change it to ext.kotlin_version = '1.3.0'

This should be adressed ASAP. Just created a new Flutter project yesterday and I had to fix this issue from like 1 year ago today:
Change Kotlin to:
ext.kotlin_version = '1.3.0'
and Gradle to:
classpath 'com.android.tools.build:gradle:3.3.1'

If this is the support that Google tries to sell, I am not seeing it. Inacceptable for a Framework that wants to gain traction...

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.

Yeah, this worked perfectly! Thanks

like hydra,resolve one and growth two.

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)

I had just migrated to AndroidX and was in the process of implementing firebase_core and firebase_messaging, when I came across this error. Migrating to Gradle 3.3.1 as @david-mccoy mentioned fixed the issue for me. Thanks!

this is very bad, very annoying, every time i start a new project with Flutter i have to edit several files from android folder for the compile project, like "gradle.properties" adding the lines

android.useAndroidX = true
android.enableJetifier = true

edit the file "android / build.gradle"

Set Gradle to 3.3.1 instead of 3.2.1
Add dependency com.google.gms: google-services: 4.3.2
Set kotlin version to 1.3.0 ext.kotlin_version = '1.3.0'

edit android / app / build.gradle

add Firebase SDK
implementation 'com.google.firebase: firebase-analytics: 17.2.0'

add SDKs to any other Firebase product
https://firebase.google.com/docs/android/setup#available-libraries

add at end of file
apply plugin: 'com.google.gms.google-services'

add dependency
implementation 'com.android.support:multidex:1.0.3'

This is all very bad, it seems that Flutter is a smarter and unprofessional thing.

No need to change dependencies versions manually. Just open project with Android Studio and Refactor -> Migrate to AndroidX... and everything will work as expected.
Reference: https://flutter.dev/docs/development/androidx-migration

@theshyelf
Ideally, if you didn't have to do any of this.
Ideally, from the moment I added the package to pubspec, this would be done automatically. Similar to Nuget Xamarin packages in visual Studio

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.

after this I had to execute a flutter pub cache repair to make it build again

@insinfo For new project, you can enable AndroidX with this command: flutter create --androidx -t <project-type> <new-project-path>

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 brother, it solved my problem.

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.

Thank you. This one solve my problem today.

My solution is as follows:

  1. Change to 3.3.1 in build.grade in the project root directory, and then delete ext.kotlin_version = '1.3.31'
  2. Add it again under grade. Properties,
    Android. UseAndroidX = true
    Android. EnableJetifier = true,
    Save the first line org.gradle.jvmargs= -xmx1536m
    Delete the rest.
  3. The last sync

我的解决方案如下:
1.先在项目根目录下的build.grade中,改为3.3.1.然后删除ext.kotlin_version = '1.3.31'
2.再在grade.properties下添加,
android.useAndroidX = true
android.enableJetifier = true,
保留第一行 org.gradle.jvmargs=-Xmx1536M
其余删除.
3.最后 sync
image
image

I dont want to migrate to androidx as it doesnt support lower versions of android what to do?

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

Easy to reproduce:

  1. create a new flutter project AndroidStudio
  2. add cloud_firestore: ^0.11.0+1 to pubspec.yaml
    observe compilation errors
    Execution failed for task ':app:preDebugBuild'.

Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.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.
  • comment #cloud_firestore: ^0.11.0+1
  • execute run, observe apk is successfully generated.
    Built build/app/outputs/apk/debug/app-debug.apk.
    Installing build/app/outputs/apk/app.apk...
    Syncing files to device Redmi Note 6 Pro...
    I/zygote64(17121): Do partial code cache collection, code=30KB, data=21KB
    I/zygote64(17121): After code cache collection, code=30KB, data=21KB
    I/zygote64(17121): Increasing code cache capacity to 128KB
    Hope this helps!
    Thank you for helping with this error!
    Regards, Naveena

codefile sample:
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.orange,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.

// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State {
int _counter = 0;

void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}

@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}

Thanks so much. Worked for me

No need to change dependencies versions manually. Just open project with Android Studio and Refactor -> Migrate to AndroidX... and everything will work as expected.
Reference: https://flutter.dev/docs/development/androidx-migration

It will just say you that no use of AndroidX in current project. That's it, you have to make manual changes.

My solution is as follows:

  1. Change kotlin_version from 1.2.71 to 1.3.0
  2. Change gradle version from 3.2.1 to 3.3.1

had to have a flutter command to check and fix the project automatically.

I've made the updates but still get the same error:
image

the error indicates that Kotlin version was not updated.

image
This is happening when using image_picker: ^0.6.2+3 . with cloud_firestore: ^0.13.0+1

Same as @bdairy , just added _image_picker_ and I have the problem:
cloud_firestore: ^0.13.0+1
firebase_storage: ^3.1.1
image_picker: ^0.6.3

Solved with:

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"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

The issue is that the project is likely using an older version of Gradle, Android Gradle plugin and Kotlin.

If you still see this issue, ensure:

  1. <app-dir>/android/build.gradle contains this section:

```.groovy
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

2. `<app-dir>/android/gradle/wrapper/gradle-wrapper.properties` contains this code:
```.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
  1. Ensure the app is migrated to AndroidX:
    .properties org.gradle.jvmargs=-Xmx1536M android.enableR8=true android.useAndroidX=true android.enableJetifier=true

cc @zanderso this is another instance of files getting out of sync. We don't see these issues in the devicelab because we only test against a single combination of these dependencies.

@blasten thanks for the reply,, But really all these settings are exactly the same,, yet I am still getting the same error. I even run flutter clean.. check the screen shots and flutter doctor. This stopping my work I would really appreciate your help guys.. thanks
image

image
image
image
image

Same as @bdairy , just added _image_picker_ and I have the problem:
cloud_firestore: ^0.13.0+1
firebase_storage: ^3.1.1
image_picker: ^0.6.3

Solved with:

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"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

THanks @JuanjoA but Still getting the same error. I think I need to configure something ,, I am really lost.

@blasten is there any fix coming soon.. I am working in iOS now but I my submission is so close.. is there any suggestions that can get things fixed??? Thank

@blasten is there any fix coming soon.. I am working in iOS now but I my submission is so close.. is there any suggestions that can get things fixed??? Thank

I can help you to fix in android but ios I am not sure.

@blasten is there any fix coming soon.. I am working in iOS now but I my submission is so close.. is there any suggestions that can get things fixed??? Thank

I can help you to fix in android but ios I am not sure.

@sethladd I don't have an issue on iOS,, the problem is only android issue,, please help :)

@blasten is there any fix coming soon.. I am working in iOS now but I my submission is so close.. is there any suggestions that can get things fixed??? Thank

I can help you to fix in android but ios I am not sure.

@sethladd I don't have an issue on iOS,, the problem is only android issue,, please help :)

Setting up firebase:

Use gms service version as shown in the code below in app.gradle instead of 4.3.2 or any other version :

classpath 'com.google.gms:google-services:4.2.0'

Add this snippet to build.gradle below dependencies:

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

Change dependenicie in build.gradle (outside of app->build.gradle)
classpath 'com.android.tools.build:gradle:3.3.1'
note that initially its 3.2.1 or can be some other version too.

change kotlin version to 1.3.0 from 1.2.71 or something else

goto gradle.properties and paste this snippet of code:

android.useAndroidX = true
android.enableJetifier = true

Do let me know if you face problems locating any folder

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??

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?

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 ..

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

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...

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

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.

@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: https://github.com/thyagoluciano/flutter_launch_whatsapp/commit/d29f6359d339286519d682fb19dc4b48d3de0625

@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

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.

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
?

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

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.

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

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

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

One of the Best Github Issue Discussion I have ever seen

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

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?

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!

Was this page helpful?
0 / 5 - 0 ratings