You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Flutter应用App Bundle体积从19.4MB骤增至139MB的排查求助

Flutter应用App Bundle体积从19.4MB骤增至139MB的排查求助

大家好,我最近遇到了一个特别头疼的问题,想请社区的朋友们帮忙分析排查下:

我的Flutter应用在上一个正式版本的App Bundle体积只有19.4MB,这次迭代我只做了些小bug修复——没有任何功能重大更新,也没新增图片或其他资源文件,但最新构建的App Bundle体积居然直接飙升到了139.6MB!更诡异的是,针对arm64架构单独打包的release APK体积还是正常的20MB左右,这完全超出了我的预期,实在摸不着头脑。

我已经做的优化配置

为了控制包体积,我已经开启了这些优化操作:

  • 启用了 minifyEnabledshrinkResources
  • 尝试移除了 debugSymbolLevel 'FULL'(不过当前build.gradle配置里还能看到这个设置,我正在调整验证)

以下是我当前的release构建配置:

release {
    minifyEnabled true // obfuscate code and remove unused code
    shrinkResources true // shrink and remove unused resources
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    ndk {
        debugSymbolLevel 'FULL'
    }
    signingConfig signingConfigs.debug
    debuggable false // make app non-debuggable
    crunchPngs true // shrink images
    jniDebuggable false
    renderscriptDebuggable false
    pseudoLocalesEnabled false
    zipAlignEnabled true
}

Flutter Doctor 输出信息

我也检查了本地Flutter环境的状态,以下是flutter doctor的完整输出:

[√] Flutter (Channel stable, 3.32.5, on Microsoft Windows [Version 10.0.19043.2364], locale en-US) [521ms]
    • Flutter version 3.32.5 on channel stable at E:\SDK\sdk\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fcf2c11572 (4 weeks ago), 2025-06-24 11:44:07 -0700
    • Engine revision dd93de6fb1
    • Dart version 3.8.1
    • DevTools version 2.45.1
[√] Windows Version (10 Pro 64-bit, 21H1, 2009) [1,501ms]
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [6.6s]
    • Android SDK at E:/SDK/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = E:/SDK/sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.
[√] Chrome - develop for the web [22ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[X] Visual Studio - develop Windows apps [20ms]
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.2) [17ms]
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
[√] VS Code (version 1.100.2) [15ms]
    • VS Code at C:\Users\sukaina\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected device (3 available) [268ms]
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.2364]
    • Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.158
    • Edge (web) • edge • web-javascript • Microsoft Edge 138.0.3351.95
[√] Network resources [753ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.
Process finished with exit code 0

我使用的构建命令

  • 构建App Bundle:flutter build appbundle --release
  • 构建arm64 APK并分析体积:flutter build apk --release --target-platform android-arm64 --analyze-size

目前我已经反复检查了项目资源文件,确认没有意外引入大文件,也验证了混淆和资源压缩功能正常开启,但还是找不到App Bundle体积暴增的根源。有没有朋友遇到过类似的问题?或者能给我一些具体的排查方向建议?非常感谢!

内容来源于stack exchange

火山引擎 最新活动