优点
1、网上随处可见的就不再赘述了,我最受益的就是 比Compose更快的及时刷新,我可以在我的Android设备上以最短的延迟见到我写的界面
槽点
1、插件对Android GRADLE和AGP 版本的向下兼容不好,易出现如下
csharp
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> 3 issues were found when checking AAR metadata:
1. Dependency 'androidx.browser:browser:1.9.0' requires Android Gradle plugin 8.9.1 or higher.
This build currently uses Android Gradle plugin 8.7.3.
此时有两个选择,第一是升级AGP ,风险是引发其他插件问题,第二选择是逐个尝试插件的版本 ,如果该插件(此时我用的是url_launcher) 每个低版本都不能适配我的Android环境,那么我可能只能改为第一个选择了。
2、问题1 我选择了第一方案后 ,重新编译工程是小时级别的了 ,gradle文件都在本地 ,不知道他在下载什么
agsl
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Font asset "td_icons.ttf" was tree-shaken, reducing it from 367144 to 1536 bytes (99.6% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 2160 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseNativeLibs'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
> Failed to transform armeabi_v7a_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar (io.flutter:armeabi_v7a_release:1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6) to match attributes {artifactType=android-jni, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download armeabi_v7a_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar (io.flutter:armeabi_v7a_release:1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6)
> Could not get resource 'https://storage.flutter-io.cn/download.flutter.io/io/flutter/armeabi_v7a_release/1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6/armeabi_v7a_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar'.
> Read timed out
> Failed to transform arm64_v8a_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar (io.flutter:arm64_v8a_release:1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6) to match attributes {artifactType=android-jni, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download arm64_v8a_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar (io.flutter:arm64_v8a_release:1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6)
> Could not get resource 'https://storage.flutter-io.cn/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6/arm64_v8a_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar'.
> Premature end of Content-Length delimited message body (expected: 38,957,021; received: 3,440,640)
> Failed to transform x86_64_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar (io.flutter:x86_64_release:1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6) to match attributes {artifactType=android-jni, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Could not download x86_64_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar (io.flutter:x86_64_release:1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6)
> Could not get resource 'https://storage.flutter-io.cn/download.flutter.io/io/flutter/x86_64_release/1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6/x86_64_release-1.0.0-e4b8dca3f1b4ede4c30371002441c88c12187ed6.jar'.
> Read timed out
* 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 generate a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.
BUILD FAILED in 20m 27s
Running Gradle task 'assembleRelease'... 1228.4s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #1, wait time: 100ms
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Font asset "td_icons.ttf" was tree-shaken, reducing it from 367144 to 1536 bytes (99.6% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 2160 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Running Gradle task 'assembleRelease'... //
这是AI给的解决方案 ,重试即可 哈哈哈
agsl
这个错误**跟 url_launcher 无关**,是 Gradle 下载 Flutter 引擎 jar 文件时网络中断导致的:
Premature end of Content-Length delimited message body (expected: 170,894,936; received: 4,407,243)
r
即需要下载约 163MB 的 `arm64_v8a_debug.jar`,但只收到了约 4MB 就断了,是 `storage.flutter-io.cn` 镜像下载不稳定。
**解决方案**:
1. **清除 Gradle 缓存中损坏的下载文件,然后重试**:
```powershell
# 删除损坏的缓存
Remove-Item -Recurse -Force "$env:USERPROFILE.gradle\caches\transforms-*" -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force "$env:USERPROFILE.gradle\caches\modules-2\files-2.1\io.flutter" -ErrorAction SilentlyContinue
- 重新运行构建:
powershell
fvm flutter run
如果镜像源持续不稳定,可以尝试换个网络环境(比如开热点/VPN),或者多试几次。这个 jar 是 Flutter 引擎文件,首次下载成功后会缓存,后续就不用再下了。