首页 > 解决方案 > 可以在调试模式下构建应用程序,但不能在发布模式下 Flutter

问题描述

在发布模式下运行时,我在控制台中遇到以下错误。

C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:19: error: cannot find symbol
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
                                                    ^
  symbol:   class FlutterLifecycleAdapter
  location: package io.flutter.embedding.engine.plugins.lifecycle
C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps\Googl
eMapsPlugin.java:92: error: cannot find symbol
    lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
                ^
  symbol:   variable FlutterLifecycleAdapter
  location: class GoogleMapsPlugin
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Bilal Saeed\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\google_maps_flutter-2.1.0\android\src\main\java\io\flutter\plugins\googlemaps
\TileProviderController.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':google_maps_flutter:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 3m 14s
Running Gradle task 'assembleRelease'...                          195.8s
Gradle task assembleRelease failed with exit code 1

到目前为止我所尝试的。

  1. 将此行添加到 gradle.properties。
org.gradle.jvmargs=-Xmx4608m
  1. 在 Android Studio 中
File > Invalidate Caches/Restart... 
    • 删除了完整的pub_cache 文件夹
    • 重新启动我的 Android Studio。
    • flutter clean,,,。flutter pub get_flutter upgrade
  1. 也跑了flutter pub cache repair命令。

但没有解决方案奏效。

标签: flutterdart

解决方案


对我有用的东西可能会帮助其他人。

1.删​​除项目android文件夹中的.gradle文件。

2.将项目级 build.gradle 文件中的类路径悬停在最新版本上。

3. 升级了gradle-wrapper.properties中的分发URL

4.单击文件/使缓存无效并重新启动选项。它再次开始发布我的应用程序。


推荐阅读