Flutter app Android studio 3.2.1,构建失败

Posted

技术标签:

【中文标题】Flutter app Android studio 3.2.1,构建失败【英文标题】:Flutter app Android studio 3.2.1, build fail 【发布时间】:2019-03-31 21:14:37 【问题描述】:

我将 android Studio 更新到 3.2.1 并在 Mac 的终端中运行“flutter build apk”,它显示以下错误。在更新 Android Studio 之前,我能够成功构建 apk。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

这里是我的 proguard-rules.pro

#Flutter Wrapper
-keep class io.flutter.app.**  *; 
-keep class io.flutter.plugin.**   *; 
-keep class io.flutter.util.**   *; 
-keep class io.flutter.view.**   *; 
-keep class io.flutter.**   *; 
-keep class io.flutter.plugins.**   *; 
-keep class com.google.firebase.**  *; 

【问题讨论】:

***.com/q/33877134/10269042 【参考方案1】:

这解决了我的问题,

 #Flutter Wrapper
-keep class io.flutter.app.**  *; 
-keep class io.flutter.plugin.**   *; 
-keep class io.flutter.util.**   *; 
-keep class io.flutter.view.**   *; 
-keep class io.flutter.**   *; 
-keep class io.flutter.plugins.**   *; 
-dontwarn android.**

在这里查看解释: https://github.com/flutter/flutter/issues/40218#issuecomment-531047713

【讨论】:

【参考方案2】:

转到 android/app/build.gradle 并尝试 minifyEnabled false 它应该可以工作

【讨论】:

以上是关于Flutter app Android studio 3.2.1,构建失败的主要内容,如果未能解决你的问题,请参考以下文章

Flutter - 播放来自平台特定文件夹的声音文件(例如 Android 的 android/app/src/main/res/raw)

Flutter App打包配置(android平台)

Flutter App打包配置(android平台)

Flutter_设置APP图标和启动图

FAILURE:构建失败并出现异常。 * 其中:构建文件 'D:\AProjects\flutter_app\android\app\build.gradle' 行:24

Flutter web app中注入Android对象的Android webview调用方法