Harsh Bhavsar
Harsh Bhavsar

Reputation: 1671

Execution failed for task ':app:preDebugBuild'.in Flutter

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

I have added List of plugins in my flutter app

dependencies:
  flutter:
    sdk: flutter
  connectivity:
  rxdart:
  validate: ^1.7.0
  image_picker: ^0.4.10
  shared_preferences: "^0.4.2"
  firebase_auth: ^0.6.2+1
  google_sign_in:

Dart & Flutter version : Dart 2.1.0-dev.3.1.flutter-760a9690c2

This is my android app - gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

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 27

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.standardappstructure"
        minSdkVersion 16
        targetSdkVersion 27
        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.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'

Destribution Gradle version :

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

Project level : gradle

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.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
}

If I am changing gradle classpath to

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

Its showing me

Android dependency 'android.arch.lifecycle:runtime' has different version for the compile (1.0.0) and runtime (1.1.0) classpath. You should manually set the same version via DependencyResolution

Upvotes: 7

Views: 11399

Answers (3)

Tandoh Anthony Nwi-Ackah
Tandoh Anthony Nwi-Ackah

Reputation: 2175

I added implementation("com.android.support:support-v4:latest_version_number") to my build.gradle and it worked.Hope this helps.

Upvotes: 2

Hardik Kumbhani
Hardik Kumbhani

Reputation: 2021

You can solve this error with below code change in android>build.gradle

If your project config with kotlin then

   ext.kotlin_version = '1.2.71'

     replace with new version

   ext.kotlin_version = '1.3.0'

and

dependencies {classpath 'com.android.tools.build:gradle:3.2.1'}
                    replace with new version
dependencies {classpath 'com.android.tools.build:gradle:3.3.0'}

You probably get your obstacles if your exception is

What went wrong: Execution failed for task ':app:preDebugBuild'. Android dependency 'androidx.exifinterface:exifinterface' 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

Upvotes: 2

Brinda Rathod
Brinda Rathod

Reputation: 2903

cloud_firestore: ^0.8.2+3
firebase_auth: ^0.6.5
image_picker: 0.4.0

This works for me

Upvotes: 1

Related Questions