ビルドエラー
$ flutter build apk --release --flavor production --dart-define=FLAVOR=production
Running "flutter pub get" in castlinxmobile... 3.3s
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
This application cannot tree shake icons fonts. It has non-constant instances of IconData at the following locations:
- lib/screen/aaaa/xxxx.dart:624:31
- lib/screen/aaaa/yyyy.dart:139:35
FAILURE: Build failed with an exception.
原因の箇所
IconData(0xea62, fontFamily: 'MaterialIcons'),
どうやら、IconDataを指定しているのが原因のよう
対処法
オプションに
--no-tree-shake-icons
を指定する
下記実行結果
$ flutter build apk --release --flavor production --dart-define=FLAVOR=production --no-tree-shake-icons
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
注意:/usr/local/bin/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.javaは非推奨のAPIを使用またはオーバーライドしています。
注意:詳細は、-Xlint:deprecationオプションを指定して再コンパイルしてください。
注意:/usr/local/bin/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-7.0.1/android/src/main/java/io/flutter/plugins/firebaseanalytics/FirebaseAnalyticsPlugin.javaは非推奨のAPIを使用またはオーバーライドしています。
注意:詳細は、-Xlint:deprecationオプションを指定して再コンパイルしてください。
Running Gradle task 'assembleProductionRelease'...
Removed unused resources: Binary resource data reduced from 802KB to 802KB: Removed 0%
Running Gradle task 'assembleProductionRelease'...
Running Gradle task 'assembleProductionRelease'... Done 183.8s (!)
✓ Built build/app/outputs/flutter-apk/app-production-release.apk (69.3MB).
参考記事