flutter Gradle任务assembleRelease失败,退出代码为% 1错误

oxf4rvwz  于 2023-04-22  发布在  Flutter
关注(0)|答案(2)|浏览(610)

它给出了这样的错误时,试图使此文件的apk.

C:\flutter\bin\flutter.bat --no-color build apk

Building without sound null safety

[!] Your app isn't using AndroidX.
    To avoid potential build failures, you can quickly migrate your app by following the steps on .
Running Gradle task 'assembleRelease'...                        

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Alp\AndroidStudioProjects\InstaUI\android\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Failed to notify project evaluation listener.
      > AndroidX must be enabled when Jetifier is enabled. To resolve, set android.useAndroidX=true in your gradle.properties file.
      > Could not get unknown property 'ndkVersion' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

* 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.

BU�LD FAILED in 6s
Running Gradle task 'assembleRelease'...                            7,1s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1
uajslkp6

uajslkp61#

对于first error,即AndroidX must be enabled when Jetifier is enabled. To resolve, set android.useAndroidX=true in your gradle.properties file.
gradle.properties文件中添加以下两行。

android.useAndroidX=true
android.enableJetifier=true

对于second error,根据错误消息Could not get unknown property 'ndkVersion' for extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.,您需要执行以下操作:
导航到android >> app >> build.gradle,将您的flutter.ndkVersion更改为最新的稳定版本,您可以查看最新的NDK稳定版本here

相关问题