【发布时间】:2020-01-25 18:57:21
【问题描述】:
我在 android studio 中运行这个命令来构建一个 apk,但是我收到这个错误“Gradle 失败可能是因为这个 Flutter 应用程序中的 AndroidX 不兼容。”我尝试了很多东西,但问题仍然存在我该如何解决这个问题
C:\Users\Waqas\AndroidStudioProjects\gtvsports>flutter build apk
You are building a fat APK that includes binaries for android-arm, android-arm64.
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
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 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle... 1.4s
Resolving dependencies... 4.7s
Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.3.1-5013011-windows Daemon #0: Unexpected error during compile 'C:\U
sers\Waqas\AndroidStudioProjects\gtvsports\android\app\src\main\res\drawable\bg.png', attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
* 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 56s
Running Gradle task 'assembleRelease'... 57.1s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See <link here > for more information on the problem and how to fix it.
*******************************************************************************************
Gradle task assembleRelease failed with exit code 1
【问题讨论】:
-
好吧,你尝试了什么?
-
请分享您尝试解决的问题,以免我们重复。另外,我假设您已经访问了底部错误消息中提到的链接。
-
在 medium 上查看这篇文章,它可能会对您有所帮助
-
我已将 android.useAndroidX=true android.enableJetifier=true 设置为 gradle.properties 这个文件我什至尝试通过遵循这篇文章flutter.dev/docs/development/packages-and-plugins/…来避免使用 android X
标签: android-studio flutter dart flutter-dependencies