I have an app that I have been using successfully in chrome (web). I did have it working in apk (android) but now the build fails. I have been getting multiple different errors and have tried many suggestions coming from github gemini with no success. So I suspect there are errors in my gradle files, because of suggestions from gemini. I was mostly working with AndroidStudio Narwhal, but the following output is all without AndroidStudio running
I have done
flutter clean
flutter pub get
./gradlew clean
rm -rf ~/.gradle/caches/
'''
uname -a
Linux PostCovid 6.8.0-62-generic #65-Ubuntu SMP PREEMPT_DYNAMIC Mon May 19 17:15:03 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
- - - -
flutter doctor -v
[✓] Flutter (Channel stable, 3.32.5, on Ubuntu 24.04.2 LTS 6.8.0-62-generic, locale en_CA.UTF-8) [105ms]
• Flutter version 3.32.5 on channel stable at /home/doug/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fcf2c11572 (3 days ago), 2025-06-24 11:44:07 -0700
• Engine revision dd93de6fb1
• Dart version 3.8.1
• DevTools version 2.45.1
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [2.1s]
• Android SDK at /home/doug/Android/Sdk
• Platform android-35, build-tools 35.0.1
• ANDROID_SDK_ROOT = /home/doug/Android/Sdk
• Java binary at: /home/doug/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
• All Android licenses accepted.
[✓] Chrome - develop for the web [21ms]
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop [170ms]
• Ubuntu clang version 18.1.3 (1ubuntu1)
• cmake version 3.28.3
• ninja version 1.11.1
• pkg-config version 1.8.1
! Unable to access driver information using 'eglinfo'.
It is likely available from your distribution (e.g.: apt install mesa-utils)
[✓] Android Studio (version 2025.1.1) [19ms]
• Android Studio at /home/doug/.local/share/JetBrains/Toolbox/apps/android-studio/
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• android-studio-dir = /home/doug/.local/share/JetBrains/Toolbox/apps/android-studio/
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
[✓] VS Code (version unknown) [17ms]
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
✗ Unable to determine VS Code version.
[✓] Connected device (3 available) [332ms]
• SM G965W (mobile) • 3357393445533098 • android-arm64 • Android 10 (API 29)
• Linux (desktop) • linux • linux-x64 • Ubuntu 24.04.2 LTS 6.8.0-62-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.49
[✓] Network resources [625ms]
• All expected network resources are available.
• No issues found!
- - - -
flutter build apk
FAILURE: Build failed with an exception.
* What went wrong:
Could not read workspace metadata from /home/doug/.gradle/caches/8.13/kotlin-dsl/accessors/45fa3cb6b4077a86ce0b8bff6eabdd7d/metadata.bin
> /home/doug/.gradle/caches/8.13/kotlin-dsl/accessors/45fa3cb6b4077a86ce0b8bff6eabdd7d/metadata.bin (No such file or directory)
- - -
android$ more build.gradle.kts
val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
repositories {
google()
mavenCentral()
}
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
- - - -
android$ more settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
val flutterSdkPath = run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"org.jetbrains.kotlin.android" ->
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24")
"com.android.application" ->
useModule("com.android.tools.build:gradle:8.5.0")
}
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.5.0"
id("org.jetbrains.kotlin.android")
}
}
include(":app")
- - - -
android$ more app/build.gradle.kts
//import androidx.compose.ui.graphics.vector.group
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "app.web.social_sport_ladder.rg"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs += listOf("-Xextended-compiler-checks")
}
defaultConfig {
applicationId = "app.web.social_sport_ladder.rg"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 28
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
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.getByName("debug")
}
}
}
flutter {
source = "../.."
}
configurations.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin" && requested.name == "kotlin-stdlib-jdk8") {
useTarget("org.jetbrains.kotlin:kotlin-stdlib:${requested.version}")
because("kotlin-stdlib-jdk8 is deprecated and replaced by kotlin-stdlib")
}
}
}
dependencies {
implementation("androidx.lifecycle:lifecycle-runtime:2.7.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.24")
}
I am thinking of doing
mv android android.old
flutter create .
The theory being to re-create the android support using the latest flutter tools rather than trying to fix what was created before.
I will have to be careful what files I copy from android.old into android. I suspect I will need at least some lines from: