flutter build apk fails with resource linking error when using flutter_bluetooth_serial

8 hours ago 1
ARTICLE AD BOX

I’m working on a Flutter app that uses Bluetooth Serial (flutter_bluetooth_serial).

When I run the app in debug mode with flutter run, everything works fine.

However, when I build the release APK using flutter build apk --release, it fails during the Android build process with a resource linking error.

Release build fails:

flutter enter image description herebuild apk --release

Actual Error (important to include)

Execution failed for task ':flutter_bluetooth_serial:verifyReleaseResources'.

\> Android resource linking failed

ERROR: ... values.xml: ... AAPT: error: resource android:attr/lStar not found.

This indicates that one of the libraries is expecting an attribute (android:attr/lStar) that requires a higher compileSdkVersion.

My project Gradle files

android/app/build.gradle.kts

plugins { id("com.android.application") id("kotlin-android") id("dev.flutter.flutter-gradle-plugin")} android { namespace = "com.example.hc06_test" compileSdk = 34ndkVersion = flutter.ndkVersion compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = JavaVersion.VERSION_17.toString() } defaultConfig { applicationId = "com.example.hc06_test" minSdk = flutter.minSdkVersion targetSdk = 34 versionCode = flutter.versionCode versionName = flutter.versionName } buildTypes { release { signingConfig = signingConfigs.getByName("debug") } } } flutter { source = "../.." }

android/build.gradle.kts

allprojects { repositories { google() mavenCentral() } } 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) } subprojects { project.evaluationDependsOn(":app") }
Read Entire Article