6

Execution failed for task ':location:compileDebugKotlin'.

build:gradle(Module:app)

    ext.kotlin_version = '1.6.10'
    repositories {
        maven {
            //url 'https://dl.google.com/dl/android/maven2',
            url 'http://download.flutter.io'
        }
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.android.tools.build:gradle:4.+'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
        //classpath("com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.0")
    }
}

allprojects {
    repositories {
        maven {
            apply plugin: 'maven'
            //url 'https://dl.google.com/dl/android/maven2',
            url 'http://download.flutter.io'
        }
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

build:gradle(Project)

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 FileNotFoundException ("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '4'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 31

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.develpment.sported_app"
        minSdkVersion 23
        targetSdkVersion 29
        multiDexEnabled true
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
           storePassword keystoreProperties['storePassword']
       }
   }

    buildTypes {
        //release {
            release {
                profile {
                    matchingFallbacks = ['debug', 'release']
                }
                minifyEnabled true
                useProguard true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.release
            }
        //}
    }
    lintOptions {
       disable 'InvalidPackage'
       checkReleaseBuilds false
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "com.android.support:multidex:1.0.3"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'com.android.support:support-annotations:28.0.0'
}

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

Solution Tried:

  1. Invalidate Caches/Restart
  2. Build -> Clean Project
  3. Updated Kotlin Plugin and used latest Kotlin version
  4. Run ./gradlew assembleDebug
  5. Run flutter doctor and flutter clean

Previously I tried to build for release and the release build, but some features weren't working. So I looked around and found that I was supposed to add the code below in the main method in the MainActivity.kt in the android section, that's when this issue started. I even tried to comment out the method but the error is still there.

override fun configureFlutterEngine(@NonNull flutterEngine:FlutterEngine){GeneratedPluginRegistrant.registerWith(flutterEngine);}

2
  • I had the same problem and what fix it for me was switching flutter back to stable channel flutter channel stable (I was on beta because I wanted to use the expansionTileTheme). Commented Apr 11, 2022 at 18:27
  • I am also having the same error after updating to Flutter 3 from Flutter 2 and updating all my packages and doing all the same exact steps as you!! Were you able to resolve this @hamsoace Commented May 21, 2022 at 10:57

5 Answers 5

6

I updated all my project packages. That solved the issue for me.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, running flutter pub upgrade then flutter clean then flutter pub get fixed this for me.
3

This actually worked for me

flutter pub upgrade
flutter clean
flutter pub get

Comments

2

You need to equalize kotlin version in first row which is ext.kotlin_version = '1.6.10' to according to classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" of underlined $kotlin_version

After this, problem will solve...

4 Comments

Sorry but what do you mean by equalize the kotlin version coz i've done it the same as you suggested
Okay, im going to explain for you. When i started a new project, my ext.kotlin_version='1.6.10' but this gives me an error. It says changing to 1.6.20. After i changed the code, it starts to work
Still got the same error
In my case, I adjust the ext.kotlin_version to match the package that is causing an error. I do this by checking the Kotlin version inside the android/build.gradle file of that package.
2

I'm also faced same issue, I done with below changes. But it's a temporary bug fix. For more reference

Search for the FlutterLocationService.kt and edit it change the function:

onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?): Boolean

to

onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray): Boolean

Comments

0

update ext.kotlin_version to latest from here https://kotlinlang.org/docs/releases.html#release-details

android->build.gradle

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.