android - Flutter build apk 无法在 android studio 上运行
问题描述
我可以在我的手机上以调试模式运行该应用程序。但是当我通过在 Android Studio 上选择生成.apkBuild>Flutter>Build APK
时,它显示以下错误:
/home/suraj/Softwares-and-tools/flutter/bin/flutter --no-color build apk
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
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':path_provider:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/home/suraj/.gradle/caches/transforms-2/files-2.1/a9db740b60dc36334c2480530f66f4a2/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/home/suraj/.gradle/caches/transforms-2/files-2.1/a9db740b60dc36334c2480530f66f4a2/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
* 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 29s
Running Gradle task 'assembleRelease'... 29.7s
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin flutter_plugin_android_lifecycle...
Running Gradle task 'assembleAarRelease'... 0.7s
FAILURE: Build failed with an exception.
* What went wrong:
Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 0s
The plugin flutter_plugin_android_lifecycle could not be built due to the issue above.
Process finished with exit code 1
我也尝试在我的手机上运行该应用程序,Run>Flutter run 'main.dart' in release mode
但这也不起作用。以前可以在发布模式下运行,但后来我不确定出了什么问题。
请帮忙
解决方案
尝试使用命令:
flutter clean
然后,尝试构建 apk。如果这仍然不起作用,请尝试Invalidate caches/restart
Android Studio。
推荐阅读
- github - Github 拉取请求被标记为关闭但仍处于打开状态,有什么办法绕过吗?
- php - 如何使用 WHERE LIKE (或等效)搜索 Laravel 集合
- javascript - 使用用户输入响应更改 iframe src
- google-apps-script - 我无法从 RichTextValue 获取文本
- c++ - 如何计算两个圆相交的面积?
- javascript - 将 .js 制作的表格打印到 html
- php - Laravel 时间验证规则
- reactjs - 在“Connect(App)”的上下文中找不到“store”。- React npm 测试期间的错误消息
- editor - 在 vis 编辑器中,标记一行,在冒号命令中使用相同的标记行
- asynchronous - 有哪些流行的框架可用于实现 CQRS、事件溯源和 Saga 以实现数据一致性和分布式事务?