androidfluttergradlebuild.gradle

Flutter - A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction


I've opened a Flutter project that was created in 2023 and saw an error: 'Deprecated imperative apply of Flutter's Gradle plugins'. To get rid of the error, I've done steps in there: Deprecated imperative apply of Flutter's Gradle plugins, and that error was gone. After that, this error happened:

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction

build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

settings.gradle:

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
 }

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0" // apply true
    id "com.android.application" version "7.3.0" apply false
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

include ":app"

pubspec.yaml

name: alphabetly
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+2

environment:
  sdk: '>=3.1.5 <4.0.0'

dependencies:
  audioplayers: ^5.2.0
  change_app_package_name: ^1.1.0
  day_night_switch: ^1.0.4
  flutter:
    sdk: flutter
  flutter_launcher_icons: ^0.13.1
  shared_preferences: ^2.2.2

 dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icon/icon.png"
  remove_alpha_ios: true

flutter:
  uses-material-design: true
  assets:
  - assets/

Error:

e: file:///home/galib/Apps/flutter_linux_3.13.7-stable/flutter/packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt:764:21 Unresolved reference: filePermissions
e: file:///home/galib/Apps/flutter_linux_3.13.7-stable/flutter/packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt:765:25 Unresolved reference: user
e: file:///home/galib/Apps/flutter_linux_3.13.7-stable/flutter/packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt:766:29 Unresolved reference: read
e: file:///home/galib/Apps/flutter_linux_3.13.7-stable/flutter/packages/flutter_tools/gradle/src/main/kotlin/FlutterPlugin.kt:767:29 Unresolved reference: write

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':gradle:compileKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

How to get rid of this error?


Solution

  • You must be update gradle in your project.

    go this file android/gradle/wrapper/gradle-wrapper.properties

    change as distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip

    and update your plugins;

    plugins {
        id "com.android.application" version "8.4.2" apply false
        id "com.android.library"    version "8.4.2" apply false
        id "org.jetbrains.kotlin.android" version "1.9.24" apply false
    }