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

'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (27.0.1) classpath #14020

Closed
romaluca opened this issue Jan 10, 2018 · 20 comments

Comments

@romaluca
Copy link

romaluca commented Jan 10, 2018

i receive an error when i run flutter run

flutter run
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...                                0.7s
Resolving dependencies...                             0.9s
Running 'gradlew assembleDebug'...                        
Configuration 'debugCompile' in project ':app' is deprecated. Use 'debugImplementation' instead.
Configuration 'profileCompile' in project ':app' is deprecated. Use 'profileImplementation' instead.
Configuration 'releaseCompile' in project ':app' is deprecated. Use 'releaseImplementation' instead.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
Configuration 'debugProvided' in project ':apn_fb_login' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':apn_fb_login' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'debugProvided' in project ':firebase_messaging' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':firebase_messaging' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'debugProvided' in project ':google_sign_in' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':google_sign_in' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'debugProvided' in project ':image_picker' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':image_picker' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'debugProvided' in project ':share' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':share' is deprecated. Use 'releaseCompileOnly' instead.
Configuration 'debugProvided' in project ':shared_preferences' is deprecated. Use 'debugCompileOnly' instead.
Configuration 'releaseProvided' in project ':shared_preferences' is deprecated. Use 'releaseCompileOnly' instead.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:appcompat-v7' has different version for the compile (26.1.0) and runtime (27.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.

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

BUILD FAILED in 0s
Gradle build failed: 1

My gradle.build file is:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withInputStream { stream ->
        localProperties.load(stream)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

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

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.3'

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.shuttertop.app"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    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 {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

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

flutter doctor:

[✓] Flutter (on Linux, locale en_US.UTF-8, channel alpha)
    • Flutter at /home/luca/Programs/flutter
    • Framework revision 8f65fec5f5 (4 weeks ago), 2017-12-12 09:50:14 -0800
    • Engine revision edaecdc8b8
    • Tools Dart version 1.25.0-dev.11.0
    • Engine Dart version 2.0.0-edge.d8ae797298c3a6cf8dc9f4558707bd2672224d3e

[✓] Android toolchain - develop for Android devices (Android SDK 26.0.3)
    • Android SDK at /home/luca/Android/Sdk
    • Android NDK at /home/luca/Android/Sdk/ndk-bundle
    • Platform android-26, build-tools 26.0.3
    • ANDROID_HOME = /home/luca/Android/Sdk
    • Java binary at: /home/luca/Programs/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[✓] Android Studio (version 3.0)
    • Android Studio at /home/luca/Programs/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b01)

[✓] Connected devices
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.0.0 (API 26) (emulator)

@romaluca
Copy link
Author

romaluca commented Jan 10, 2018

I solved by adding

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

to subprojects section in android/build.gradle file

@Frankarlo
Copy link

Frankarlo commented Apr 10, 2018

is like this

buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "26.1.0"
            }
        }
    }
}

@khennny
Copy link

khennny commented Apr 29, 2018

This worked for me.Thank you.
Although I do not understand what it does.Please can you explain briefly its function ?

@Frankarlo
Copy link

i'am sorry i cannot remember why this happened, i think that this error is due when you migrate a project from an older version (e.g 2.0.1) to a newest (e.g 3.0.1) also you need to make sure you have downloaded the appropiated dependencies.

check this to get more info. https://stackoverflow.com/questions/47448502/could-not-resolve-com-android-supportappcompat-v726-1-0-in-android-studio-new

@DarshanGowda0
Copy link

DarshanGowda0 commented Jul 24, 2018

I had the same issue with flutter map_view plugin, added

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

to the end of android/build.gradle and it solved the issue.
Thanks @lalukz

@hereisderek
Copy link

imagine the hassle when we migrate to android jetpack androidx packages

@ghost
Copy link

ghost commented Jul 29, 2018

worked,
i had errors while using both clodfirestore and firebase messaging plgin now its gone by ading the above line
also adding the following line in app level gradle file

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true 

@ratsey
Copy link

ratsey commented Sep 1, 2018

Same error, but against

> Android dependency 'com.android.support:support-v4' has different version for the compile (27.0.1) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

Added this to resolve.

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

@guediagael
Copy link

When I do this my app compiles, but it crashes at the app start with no error in the logs

@dannnnthemannnn
Copy link

dannnnthemannnn commented Oct 7, 2018

I also did the 27.1.0 fix and it crashes at app start.

@lukepighetti
Copy link

lukepighetti commented Oct 8, 2018

Is there any way to resolve this without cargo culting?

@enorms
Copy link

enorms commented Oct 11, 2018

I was able to solve this in a different way. Maybe it will work for some of those who are still experiencing difficulty @dannnnthemannnn

In android/app/build.gradle add this line:
implementation "com.android.support:support-v4:27.1.1"

so it now looks like:

dependencies {
    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'
    implementation "com.android.support:support-v4:27.1.1" // added this
}

From a post on react-community.

@natezhengbne
Copy link

natezhengbne commented Nov 15, 2018

It works when I add as below

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

@kw3ku
Copy link

kw3ku commented Nov 24, 2018

the solution works fine.

@petenet001
Copy link

I had the same issue with flutter map_view plugin, added

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

to the end of android/build.gradle and it solved the issue.
Thanks @lalukz

thank you it's working for me

@yubrshen
Copy link

I was able to solve this in a different way. Maybe it will work for some of those who are still experiencing difficulty @dannnnthemannnn

In android/app/build.gradle add this line:
implementation "com.android.support:support-v4:27.1.1"

so it now looks like:

dependencies {
    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'
    implementation "com.android.support:support-v4:27.1.1" // added this
}

From a post on react-community.

Only this solution works for my situation. The one to change android/build.gradle doesn't work.

@abhishekgoyal88
Copy link

I also had the same issue and solved it by adding

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

at the end of android/build.gradle file

@irfanshaikh138
Copy link

I also had the same issue and solved it by adding

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

at the end of android/build.gradle file

this solution works for my situation.

@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 Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

17 participants