Skip to content

flutter 3.23: build android 14 Failure with agp 8.6 and Gradle 8.7 #157254

@sanbei101

Description

@sanbei101

Steps to reproduce

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          distribution: 'adopt'
          java-version: '17'

      - name: Install Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.24.3'
          channel: stable
          cache: true
      - name: Flutter Clean
        run: flutter clean

      - name: Flutter Pub Get
        run: flutter pub upgrade && flutter pub get

      - name: Set Flutter JDK
        run: flutter config --jdk-dir $JAVA_HOME

      - name: Build APK
        run: flutter build apk --split-per-abi

Expected results

Compiled successfully

Actual results

Run flutter build apk --split-per-abi

Running Gradle task 'assembleRelease'...                        
Warning: Errors during XML parse:
Warning: Additionally, the fallback loader failed to parse the XML.
Checking the license for package Android SDK Platform-Tools in /usr/local/lib/android/sdk/licenses
License for package Android SDK Platform-Tools accepted.
Preparing "Install Android SDK Platform-Tools v.35.0.2".
"Install Android SDK Platform-Tools v.35.0.2" ready.
Installing Android SDK Platform-Tools in /usr/local/lib/android/sdk/platform-tools
"Install Android SDK Platform-Tools v.35.0.2" complete.
"Install Android SDK Platform-Tools v.35.0.2" finished.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1748 bytes ([9](https://github.com/sanbei101/flutter-chat-mini/actions/runs/11433830941/job/31806404310#step:8:10)9.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Caught exception: Already watching path: /home/runner/work/flutter-chat-mini/flutter-chat-mini/android
e: file:///home/runner/work/flutter-chat-mini/flutter-chat-mini/android/app/src/main/kotlin/com/example/flutterchat/MainActivity.kt:3:8 Unresolved reference 'io'.
e: file:///home/runner/work/flutter-chat-mini/flutter-chat-mini/android/app/src/main/kotlin/com/example/flutterchat/MainActivity.kt:5:21 Unresolved reference 'FlutterActivity'.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > 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 https://help.gradle.org.

BUILD FAILED in 2m 1s
Running Gradle task 'assembleRelease'...                          [12](https://github.com/sanbei101/flutter-chat-mini/actions/runs/11433830941/job/31806404310#step:8:13)2.3s
Gradle task assembleRelease failed with exit code 1
Error: Process completed with exit code 1.

Code sample

android/app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

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

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

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

android {
    namespace = "com.example.flutterchat"
    compileSdkVersion 34
    buildToolsVersion "34.0.0"
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.flutterchat"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = 34
        targetSdk = 34
        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 = "../.."
}

android/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 'com.android.application' version '8.6.0' apply false
    id 'com.android.library' version '8.6.0' apply false
    id 'org.jetbrains.kotlin.android' version '2.0.20' apply false
}

include ":app"
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

I modified the agp version on github workspace on the preview project, so there are no doctor output conditions
but the action maybe speak

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          distribution: 'adopt'
          java-version: '17'

      - name: Install Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.24.3'
          channel: stable
          cache: true
      - name: Flutter Clean
        run: flutter clean

      - name: Flutter Pub Get
        run: flutter pub upgrade && flutter pub get

      - name: Set Flutter JDK
        run: flutter config --jdk-dir $JAVA_HOME

      - name: Build APK
        run: flutter build apk --split-per-abi

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions