I am new to flutter development and so far I have been testing the android app in debug mode. I want to release the app to share with friends and family. However, I keep getting errors when I try to build the apk (release).
To be honest, I do not fully understand the build.gradle files; hence I am reaching out here for any help, thank you.
I am on Android 14 and I intend to only support Android 14+.
I have downloaded the SDK’s for API level 34 and 35 from Android Studio.
My app is entirely on Flutter’s dart.
This is the error while building the apk (release):
Note: Recompile with -Xlint:deprecation for details.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 4212 bytes (99.7% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
aapt2 E 07-22 17:30:35 77990 77990 LoadedArsc.cpp:94] RES_TABLE_TYPE_TYPE entry offsets overlap actual entry data.
aapt2 E 07-22 17:30:35 77990 77990 ApkAssets.cpp:149] Failed to load resources table in APK '/home/username/Android/Sdk/platforms/android-35/android.jar'.
error: failed to load include path /home/username/Android/Sdk/platforms/android-35/android.jar.
android/build.gradle
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
}
android/app/build.gradle
plugins {
id "com.android.application"
id 'com.google.gms.google-services'
id "kotlin-android"
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)
}
}
android {
namespace = "com.example.flutter_application_1"
compileSdk = 35 // max SDK available today
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId = "com.example.flutter_application_1"
minSdk = 33
targetSdk = 34
versionCode = 1
versionName = "1.0"
}
buildTypes {
release {
signingConfig = signingConfigs.debug
}
}
}
flutter {
source = "../.."
}