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

时间:2019-09-25 14:32:31

标签: 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

1 个答案:

答案 0 :(得分:0)

AndroidX由Google正式发布,并且与Flutter之类的框架存在一些兼容性问题。因此,您必须按照下面给出的Flutter网站链接进行操作。

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

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