【问题标题】:app:compileFlutterBuildRelease error while building app flutterapp:compileFlutterBuildRelease 构建应用程序颤动时出错
【发布时间】:2020-10-28 01:28:12
【问题描述】:

在源代码中运行“flutter pub get”... 5.9s 正在运行 Gradle 任务“bundleRelease”...
字体中未找到代码点 58848,正在中止。

目标 aot_android_asset_bundle 失败:FontSubset 错误:字体子集失败,退出代码为 -1。

构建失败。

FAILURE:构建失败并出现异常。

  • 地点:

脚本 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' 行:838

  • 出了什么问题:

任务 ':app:compileFlutterBuildRelease' 执行失败。

Process 'command 'C:\src\flutter\bin\flutter.bat'' 以非零退出值 1 结束

  • 试试:

使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。

在 2m 52s 内构建失败 运行 Gradle 任务 'bundleRelease'... 175.2s (!) Gradle 任务 bundleRelease 失败,退出代码为 1 进程以退出代码 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 }

【问题讨论】:

  • 你有什么解决办法吗?
  • 没有兄弟还没有,你有同样的问题
  • 是的,我有。我在 pubspec.yaml 中使用 MaterialIcons 字体,我只是删除了它。
  • 你能看到我的 pubspec.yaml 并告诉我应该删除哪个部分
  • 你有解决这个问题的办法吗?

标签: android firebase android-studio flutter


【解决方案1】:

遇到同样的问题。 有了flutter build appbundle --verbose,我找到了根本原因。它基于自定义图标,这是我很久以前用http://fluttericon.com/ 构建的。

所以有3种可能的解决方案:

  1. 添加标志“--no-tree-shake-icons”
  2. 移除自定义图标
  3. 再次重新生成自定义图标

一切都会好起来的!

【讨论】:

    【解决方案2】:

    我在使用font_awesome_flutter 包时也遇到了同样的异常。

    [   +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)
    

    最后,我使用 flutter build apk --no-tree-shake-icons 进行构建

    【讨论】:

      【解决方案3】:

      我认为这行显示错误:

      Codepoint 58848 not found in font, aborting.
      

      检查您的pubspec.yaml 并查看此错误是否来自任何库。你的代码也可以在调试模式下工作吗?您是否在 pubspec 文件中添加了任何字体?

      【讨论】:

      • 在 pubspec.yaml 中只有 164 行 bro
      【解决方案4】:

      这会奏效!!!

      扑干净, 扑吧得到, flutter build appbundle --release --no-tree-shake-icons

      【讨论】:

        【解决方案5】:

        请确保您在 Flutter Stable Channel 上运行:

        flutter channel stable
        flutter upgrade --force
        

        那么当你重建时,错误就会消失。

        【讨论】:

          【解决方案6】:

          我解决了问题。 打开 FontAwesomeIcons.dart 类,搜索 E5E0(58848 的十六进制)并删除行,保存文件,然后再次构建。

          【讨论】:

            猜你喜欢
            • 2020-05-11
            • 1970-01-01
            • 2021-08-23
            • 1970-01-01
            • 2012-04-22
            • 1970-01-01
            • 2018-04-12
            • 1970-01-01
            相关资源
            最近更新 更多