flutter在使用gradle时的加速
当我使用了一些过时的插件的时候,遇到了一些问题
比如什么namespace 问题等,因为有些插件库没有更新了,或者最新版本处于测试阶段
于是我就删除这些旧插件(不符合我要求的插件)
于是根据各论坛的解决方法去做了以下的工作
1:项目中删除了这些插件
2:项目中删除了这些引用
3:删除了gradle的缓存
4:更换了新版本的gradle的版本
5:清除flutter缓存
6:重新下载构建插件
7:运行后报错
这个办法居然行不通,还是报错,于是我又得重新创建新项目
重新构建项目时总是需要很长的时间去下载插件,那么它就经常报错
报错–链接超时
那么就要设置这个个gradle的连接网络的端口
D:\F\lvjun\android\gradle.properties
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
systemProp.http.proxyHost=192.168.1.2
systemProp.http.proxyPort=1082
systemProp.https.proxyHost=192.168.1.2
systemProp.https.proxyPort=1082
这么设置之后,gradle的连接就快了
插件配置列表
name: lvjun
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: ^3.6.0
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^5.0.0
#------------------------------------
# google_fonts 超过 977 种字体(及其变体)
google_fonts: ^6.2.1
#------------------------------------
# http请求
http: ^1.2.2
# dio库是 http 请求库,不使用普通的http 库
# 【Dio 更专注于网络请求和相关功能,是一个功能强大的 HTTP 客户端。】
dio: ^5.7.0
# 用于 Dio 软件包的灵活重试库。
dio_smart_retry: ^7.0.1
# get: ^4.6.6 【Get 则是一个多合一的框架库,除了基本的网络请求,还包括了状态管理、路由管理、依赖注入等。】
get: ^4.6.6
#------------------------------------
# 打开文件
open_file: ^3.5.10
# 状态管理
provider: ^6.1.2
# path_provider 用于在文件系统上查找常用位置。
path_provider: ^2.1.5
#为简单数据封装特定于平台的持久性存储,数据可以异步保存到磁盘, 并且不能保证写入在 returning,因此此插件不得用于存储关键数据。
shared_preferences: ^2.3.4
#显示富文本内容库(使用flutter_widget_from_html显示富文本内容)
flutter_widget_from_html: ^0.15.3
# 使用url_launcher处理链接跳转
url_launcher: ^6.3.1
#------------------------------------
# 缓存管理
# cached_network_image: ^3.4.1【降低版本】
cached_network_image: ^3.4.1
#------------------------------------
# 数据库
sqlite3: ^2.6.0
sqflite: ^2.4.1
sqflite_common_ffi: ^2.3.4+4
#------------------------------------
# 加密+数学
# vector_math用于 2D 和 3D 应用程序的 Vector 数学库。
vector_math: ^2.1.4
crypto: ^3.0.6
# crypto: ^3.0.6 Dart 的一组加密哈希函数。
uuid: ^4.5.1
# uuid: ^4.5.1按字典顺序排序的 128 位标识符 (UUID),具有 48 位时间戳和 80 个随机位。
# 规范编码为 26 个字符的字符串,而不是 36 个字符的 UUID。
#------------------------------------
# 同步与异步
#同步库 基本锁定机制,用于防止并发访问异步代码。
synchronized: ^3.3.0+3
#------------------------------------
# 日志
logger: ^2.5.0
#------------------------------------
## 音频播放 音频播放功能完善,支持多种格式
just_audio: ^0.9.42
# just_audio 依赖如下
audio_session: ^0.1.23
# crypto: ^3.0.6
# path_provider: ^2.1.5
just_audio_platform_interface: ^4.3.0
just_audio_web: ^0.4.13
# path_provider: ^2.1.5
# rxdart: ^0.28.0 【降低版本】
rxdart: ^0.28.0
# uuid: ^4.5.1
# just_audio 依赖结束
#------------------------------------
# 视频播放 Flutter官方维护,稳定性好
video_player: ^2.9.2
# 依赖
video_player_android: ^2.7.17
video_player_avfoundation: ^2.6.5
video_player_platform_interface: ^6.2.3
video_player_web: ^2.3.3
# 视频播放
fvp: ^0.29.0
# 视频播放器控制器 基于 video_player 的封装,提供了更好的UI控制
plugin_platform_interface: ^2.1.8
# plugin_platform_interface: ^2.1.8 是fvp的依赖
#------------------------------------
# 播放器的控制
# chewie: ^1.8.5 【降低版本】
chewie: ^1.8.5
# wakelock_plus: 由 creativecreatorormaybenot 编写的原始唤醒锁 Flutter 插件的延续,它允许您保持设备屏幕处于唤醒状态,
# 即防止屏幕休眠。
# wakelock_plus: ^1.2.10【降低版本】
wakelock_plus: ^1.2.10
#------------------------------------
share_plus: ^10.1.3 # 分享链接 share_plus
#------------------------------------
# 显示网页1
#安卓-ios-macOS中显示网页
webview_flutter: ^4.10.0
webview_flutter_android: ^4.2.0
webview_flutter_web: ^0.2.3+4
webview_flutter_wkwebview: ^3.17.0
# 显示网页2[3中pc平台的支持]
desktop_webview_window: ^0.2.3
# webview_windows: ^0.4.0 [Windows] 仅支持windows
#------------------------------------
# 通知1 flutter_local_notifications【支持[Android-iOS-Linux-macOS]】
flutter_local_notifications: ^18.0.1
# 通知2 local_notifier 【支持 [Linux-macOS-Windows]】 依赖【uuid: ^4.5.1】
local_notifier: ^0.1.6
# uuid: ^4.5.1
#------------------------------------
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/to/asset-from-package
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/to/font-from-package
D:\F\lvjun\android\settings.gradle
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}
include ":app"
flutter版本
PS D:\F\lvjun> flutter --version
Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (4 weeks ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2
PS D:\F\lvjun>
gradle版本–以及java版本
PS D:\F> gradle -v
------------------------------------------------------------
Gradle 8.12
------------------------------------------------------------
Build time: 2024-12-20 15:46:53 UTC
Revision: a3cacb207fec727859be9354c1937da2e59004c1
Kotlin: 2.0.21
Groovy: 3.0.22
Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024
Launcher JVM: 17.0.10 (Microsoft 17.0.10+7-LTS)
Daemon JVM: C:\Program Files\Microsoft\jdk-17.0.10.7-hotspot (no JDK specified, using current Java home)
OS: Windows 11 10.0 amd64
PS D:\F>