Home > Mobile >  Execution failed for task ':fluttertoast:compileDebugKotlin'. after flutter upgrade
Execution failed for task ':fluttertoast:compileDebugKotlin'. after flutter upgrade

Time:12-18

**Error after running flutter upgrade error even after migrating the project **

A problem occurred evaluating project ':app'.

Plugin with id 'kotlin-android' not found.

app level build.gradle below

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

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

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

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

android {
    compileSdkVersion 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.garvita.phonesoft"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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 '../..' }


One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\Users\AdarshSingh\StudioProjects\phonesoft\android\app\build.gradle:
android {
  compileSdkVersion 31
  ...
}


FAILURE: Build failed with an exception.

**

    * What went wrong: Execution failed for task ':fluttertoast:compileDebugKotlin'.
    > Compilation error. See log for more details
    * 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 
    ┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐ │ [!] Your project requires a newer version of the Kotlin Gradle plugin.                       │ │ Find the latest version on  then │ │ update C:\Users\AdarshSingh\StudioProjects\phonesoft\android\build.gradle:    │ │ ext.kotlin_version = '<latest-version>'                            │ └──────────────────────────────────────────────────────────────────────────────────────────────┘ Exception: Gradle task assembleDebug failed with exit code 1

Nothing is working can anyone please give a solution or should i rollback to previous version of flutter

CodePudding user response:

I suggest to update your project (Flutter 2.8) by removing the android folder then then command line "flutter create ." To recreate the folder. You should see the variable "flutter.compileSdkVersion" in the app\build.grade.

https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

Follow that guide line. And in the android\build set "ext.kotlin_version = '1.5.30'" . Also in the project structure of android studio -> Modules -> Default Config -> Min SDK Version to 23

  • Related