Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app:compileFlutterBuildRelease error while building app flutter

Running "flutter pub get" in source... 5.9s Running Gradle task 'bundleRelease'...
Codepoint 58848 not found in font, aborting.

Target aot_android_asset_bundle failed: FontSubset error: Font subsetting failed with exit code -1.

build failed.

FAILURE: Build failed with an exception.

  • Where:

Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 838

  • What went wrong:

Execution failed for task ':app:compileFlutterBuildRelease'.

Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • 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 52s Running Gradle task 'bundleRelease'... 175.2s (!) Gradle task bundleRelease failed with exit code 1 Process finished with exit code 1

app:build.gradle

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

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with 
flutter.sdk in the local.properties file.")
}

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

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

 apply plugin: 'com.android.application'
 apply plugin: 'kotlin-android'
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

 def keystoreProperties = new Properties()
 def keystorePropertiesFile = rootProject.file('key.properties')
 if (keystorePropertiesFile.exists()) {
 keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
 }

 android {
     compileSdkVersion 28

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    applicationId "com.indianstore.onlineshopping"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
    resConfigs "en"
}

signingConfigs {
    release {

        if (System.getenv()["CI"]) { // CI=true is exported by Codemagic
            storeFile file(System.getenv()["FCI_BUILD_DIR"] +      "/indianstorekey.jks")
            storePassword System.getenv()["FCI_KEYSTORE_PASSWORD"]
            keyAlias System.getenv()["FCI_KEY_ALIAS"]
            keyPassword System.getenv()["FCI_KEY_PASSWORD"]
        } else {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }
     }

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.release
        shrinkResources true
        minifyEnabled true
        useProguard true

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

    debug {
        signingConfig signingConfigs.release
    }
     }
     compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
     }
 }

 flutter {
     source '../..'
 }

 dependencies {
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
     testImplementation 'junit:junit:4.12'
     androidTestImplementation 'androidx.test:runner:1.1.1'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
     implementation 'com.android.support:multidex:1.0.3'


 }
 apply plugin: 'com.google.gms.google-services'
 googleServices { disableVersionCheck = true }
like image 571
shiva kumar nani Avatar asked Jul 07 '20 17:07

shiva kumar nani


3 Answers

Got the same issue. With flutter build appbundle --verbose I got the root cause. It was based in custom icons, which I've built long time ago with http://fluttericon.com/.

So there are 3 possible solutions:

  1. add flag "--no-tree-shake-icons"
  2. remove custom icons
  3. re-generate custom icons again

And everything will work!

like image 119
Aleksey Pastuhov Avatar answered Oct 26 '22 01:10

Aleksey Pastuhov


I also got the same exception when using font_awesome_flutter package.

[   +2 ms] [   +4 ms] Codepoint 62694 not found in font, aborting.
[   +3 ms] [  +23 ms] Codepoint 62488 not found in font, aborting.
[   +1 ms] [  +47 ms] Target aot_android_asset_bundle failed: IconTreeShakerException: Font subsetting failed with exit code 255.
[        ]            To disable icon tree shaking, pass --no-tree-shake-icons to the requested flutter build command
[  +43 ms]            #0      IconTreeShaker.subsetFont (package:flutter_tools/src/build_system/targets/icon_tree_shaker.dart:217:7)

finally, I took build with flutter build apk --no-tree-shake-icons

like image 28
Vinoth Vino Avatar answered Oct 26 '22 02:10

Vinoth Vino


I think this line shows the error:

Codepoint 58848 not found in font, aborting.

Check your pubspec.yaml and see if this error comes from any library. Also does you code work on debug mode? Did you add any fonts in your pubspec file?

like image 1
Payam Asefi Avatar answered Oct 26 '22 02:10

Payam Asefi