flutter - 可以在调试模式下构建应用程序,但不能在发布模式下 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
到目前为止我所尝试的。
- 将此行添加到 gradle.properties。
org.gradle.jvmargs=-Xmx4608m
- 在 Android Studio 中
File > Invalidate Caches/Restart...
-
- 删除了完整的pub_cache 文件夹。
- 重新启动我的 Android Studio。
- 冉
flutter clean
,,,。flutter pub get
_flutter upgrade
也跑了flutter pub cache repair命令。
但没有解决方案奏效。
解决方案
对我有用的东西可能会帮助其他人。
1.删除项目android文件夹中的.gradle文件。
2.将项目级 build.gradle 文件中的类路径悬停在最新版本上。
3. 升级了gradle-wrapper.properties中的分发URL
4.单击文件/使缓存无效并重新启动选项。它再次开始发布我的应用程序。
推荐阅读
- json - 使用带有 Curl 的 Github 内容 API 时解析 JSON 时出错
- c# - 调用 HttpClient.PostAsync 时出现死锁
- java - Wildfly 21 - 运行应用程序客户端
- verilog - 检查一段时间内输出信号的值
- node.js - Expo-cli 安装停止并出现错误 npm ERR!cb() 从未调用过
- nibabel - 大标签文件的 nibabel.filebasedimages.ImageFileError
- java - Elasticsearch:按数组属性的长度排序
- vb.net - WebView2 浏览器不加载网页,只显示一个白色窗口
- xcode13 - XCODE 13 ISSUE with app Upload on AppStore Distribution 失败并出现错误
- javascript - Node.js mongoose 在 foreach 循环中查找查询