android-studio - 当我在android studio中运行flutter build apk命令时,出现AndroidX不兼容问题

标签 android-studio flutter dart flutter-dependencies

我正在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

最佳答案

Google正式发布了AndroidX,它与Flutter之类的框架存在一些兼容性问题。因此,您必须遵循以下给出的Flutter网站链接。

https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

我相信这会解决您的问题。

关于android-studio - 当我在android studio中运行flutter build apk命令时,出现AndroidX不兼容问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58100830/

相关文章:

android-studio - Android 设备监视器使模拟器离线

dart - Flutter:共享偏好

android - 将数据从一个屏幕发送到另一个屏幕 flutter

dart - 如何在页面加载时为元素设置焦点?

flutter - 从 Flutter 中的 Scaffold AppBar 中删除阴影?

java - android studio 0.2.2 上的 renderscript 错误

android - 从 listView 中的选定项中获取元素

android - 致命异常 - 无法实例化 Activity - 真实应用程序类为空

flutter - 点击 AppBar 打开抽屉

firebase - 在 Flutter 中收听 Firestore 集合及其子集合