I’m working on an older Flutter application that was removed from the Play Store due to outdated API levels. I’m currently trying to update and re-release it, but I’ve encountered these issues during the update process.
I need to maintain the Android minimum API level at 33, as required by the Play Store.
I’m encountering an issue while trying to compile an APK in Flutter. The error occurs during the :tflite:verifyReleaseResources
task, stating that the android:attr/lStar
resource could not be found. Below is the full error message:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':tflite:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
> Android resource linking failed
ERROR:/Users/nico/Development/novo aqua/aquahelp/build/tflite/intermediates/merged_res/release/values/values.xml:194: AAPT: error: resource android:attr/lStar not found.
* 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.
BUILD FAILED in 22s
Running Gradle task 'assembleRelease'... 22.8s
Gradle task assembleRelease failed with exit code 1
Additionally, I received several warnings about deprecated APIs in the tflite plugin that I looked around for solutions but couldn’t get very far with the fixes.
Note: /Users/nico/.pub-cache/hosted/pub.dev/tflite-1.1.2/android/src/main/java/sq/flutter/tflite/TflitePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/nico/.pub-cache/hosted/pub.dev/tflite-1.1.2/android/src/main/java/sq/flutter/tflite/TflitePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
I’ve tried running flutter clean
and flutter build apk
but the error persists. I also noticed that 14 packages have newer versions that are incompatible with the current dependency constraints.
This is the build.gradle in the android/app folder:
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
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.aquahelp"
compileSdk = 33
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
allWarningsAsErrors false
lintOptions {
disable 'Deprecation'
disable 'Unsafe'
}
}
defaultConfig {
applicationId = "com.example.aquahelp"
minSdk = 26
targetSdk = 33
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
}
buildTypes {
release {
signingConfig = signingConfigs.debug
}
}
}
dependencies {
implementation "androidx.appcompat:appcompat:1.4.0" // Atualize para androidx
implementation "androidx.core:core-ktx:1.7.0" // Atualize para androidx
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.22" // Certifique-se de que a versão do Kotlin seja compatível
}
flutter {
source = "../.."
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}
The build.gradle in the android folder:
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
My pubspec.yaml
name: aquahelp
description: A new Flutter project.
version: 1.0.0
environment:
sdk: '>=3.2.6 <4.0.0'
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.19.0
percent_indicator: ^4.2.3
image_picker: ^1.1.2
url_launcher: ^6.3.0
cupertino_icons: ^1.0.2
flutter_plugin_android_lifecycle: ^2.0.21
tflite_flutter: ^0.9.0
tflite_flutter_helper: ^0.3.0
dev_dependencies:
flutter_test:
sdk: flutter
#flutter_launcher_icons: "^0.13.1"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "icons/icon.png"
flutter:
uses-material-design: true
assets:
- assets/labels.txt
- assets/labels2.txt
- assets/model_unquant.tflite
I’ve tried cleaning the project and rebuilding the APK, checking the dependency versions, and reviewing the build.gradle files to make sure everything is set up correctly. I also updated dependencies and made sure the Kotlin version and Gradle plugin are compatible.
I also noticed that 14 packages have newer versions that are incompatible with the current dependency constraints.
Resolving dependencies...
Downloading packages...
collection 1.18.0 (1.19.0 available)
ffi 2.1.2 (2.1.3 available)
flutter_plugin_android_lifecycle 2.0.21 (2.0.22 available)
http_parser 4.0.2 (4.1.0 available)
image_picker_android 0.8.12+11 (0.8.12+13 available)
leak_tracker 10.0.5 (10.0.7 available)
leak_tracker_flutter_testing 3.0.5 (3.0.8 available)
material_color_utilities 0.11.1 (0.12.0 available)
mime 1.0.5 (1.0.6 available)
quiver 3.2.1 (3.2.2 available)
string_scanner 1.2.0 (1.3.0 available)
test_api 0.7.2 (0.7.3 available)
url_launcher_android 6.3.8 (6.3.10 available)
vm_service 14.2.4 (14.2.5 available)
Got dependencies!
14 packages have newer versions incompatible with dependency constraints.
As I’m still learning how to work with Flutter and Gradle, I’m unsure how to resolve this issue. Any guidance or suggestions on how to fix this and successfully compile the APK would be greatly appreciated. Thank you!
Adding this workaround on our android/build.gradle has resolved the issue for us.
subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin("com.android.application") ||
project.plugins.hasPlugin("com.android.library")) {
project.android {
compileSdkVersion 34
buildToolsVersion "34.0.0"
}
}
}
}
1
I know I am late but it may help the late comers like me.
If you are facing this issue even after your compileSdkVersion
and targetSdkVersion
are greater 31, then it may be due to some packages using 31 and lower compileSdkVersion or targetSdkVersion.
Adding the following lines to android/build.gradle
after rootProject.buildDir = '../build'
may solve the problem
subprojects {
afterEvaluate {
android {
compileSdkVersion 34
}
}
}
Reference is GitHub Issue