Flutter开发HarmonyOS鸿蒙Next应用的时候flutter pub get失败如何解决

发布于 1周前 作者 ionicwang 最后一次编辑是 5天前 来自 Flutter

Flutter开发HarmonyOS鸿蒙Next应用的时候flutter pub get失败如何解决
【任务描述】 设置好环境变量 执行flutter pub get 一直失败

【解决方案】 PS C:\Users\issuser\Desktop\HarmonyFlutter> flutter pub get Flutter assets will be downloaded from https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source! Running “flutter pub get” in HarmonyFlutter… Resolving dependencies… (15.5s) Authentication error (403) package:pub/src/authentication/client.dart 90:5 _AuthenticatedClient._throwAuthException package:pub/src/authentication/client.dart 56:7 _AuthenticatedClient.send ===== asynchronous gap =========================== package:pub/src/http.dart 364:30 RequestSending.fetchAsStream ===== asynchronous gap =========================== package:pub/src/source/hosted.dart 1081:28 HostedSource._download.<fn>.<fn>.<fn> ===== asynchronous gap =========================== package:pub/src/http.dart 283:60 retryForHttp.<fn>.<fn> ===== asynchronous gap =========================== package:pool/pool.dart 127:14 Pool.withResource ===== asynchronous gap =========================== package:pub/src/http.dart 283:19 retryForHttp.<fn> ===== asynchronous gap =========================== package:pub/src/utils.dart 723:14 retry ===== asynchronous gap =========================== package:pub/src/http.dart 282:10 retryForHttp ===== asynchronous gap =========================== package:pub/src/source/hosted.dart 1078:9 HostedSource._download.<fn>.<fn> ===== asynchronous gap =========================== package:pub/src/authentication/client.dart 128:12 withAuthenticatedClient ===== asynchronous gap =========================== package:pub/src/source/hosted.dart 1073:7 HostedSource._download.<fn> ===== asynchronous gap =========================== package:pub/src/io.dart 887:12 withTempDir ===== asynchronous gap =========================== package:pub/src/source/hosted.dart 1036:12 HostedSource._download ===== asynchronous gap =========================== package:pub/src/source/hosted.dart 784:21 HostedSource.downloadToSystemCache ===== asynchronous gap =========================== package:pub/src/system_cache.dart 230:20 SystemCache.downloadPackage ===== asynchronous gap =========================== package:pub/src/solver/result.dart 70:20 SolveResult.downloadCachedPackages.<fn>.<fn> ===== asynchronous gap =========================== package:pub/src/solver/result.dart 68:18 SolveResult.downloadCachedPackages.<fn> ===== asynchronous gap =========================== package:pub/src/solver/result.dart 65:32 SolveResult.downloadCachedPackages ===== asynchronous gap =========================== package:pub/src/entrypoint.dart 372:25 Entrypoint.acquireDependencies ===== asynchronous gap =========================== package:pub/src/command/get.dart 60:5 GetCommand.runProtected This is an unexpected error. The full log and other details are collected in:

D:\pubcache\log\pub_log.txt

Consider creating an issue on https://github.com/dart-lang/pub/issues/new and attaching the relevant parts of that log file. pub get failed command: “C:\Users\issuser\flutter_flutter\bin\cache\dart-sdk\bin\dart __deprecated_pub --color --directory . get --example” pub env: { “FLUTTER_ROOT”: “C:\Users\issuser\flutter_flutter”, “PUB_ENVIRONMENT”: “flutter_cli:get”, “PUB_CACHE”: “D:\pubcache”, } exit code: 1

【任务来源】 这是啥问题

1 回复

在Flutter开发HarmonyOS(鸿蒙)Next应用时遇到flutter pub get失败的问题,通常可能由以下几种原因引起:

  1. 网络连接问题:确保你的开发环境可以连接到Flutter的pub.dev仓库。如果是网络问题,尝试更换网络环境或使用代理。

  2. Flutter SDK版本:检查你的Flutter SDK版本是否与HarmonyOS Next应用的开发要求相匹配。可能需要更新Flutter SDK或切换到特定的版本。

  3. Pub缓存问题:尝试清除pub缓存,运行flutter pub cache repair命令来修复可能存在的缓存问题。

  4. 依赖冲突:检查pubspec.yaml文件中的依赖是否有冲突或版本不兼容的情况。确保所有依赖都是最新的,或至少是相互兼容的版本。

  5. 配置文件错误:确保pubspec.yaml文件格式正确,没有语法错误。

  6. 鸿蒙开发环境配置:确认你的鸿蒙开发环境(如DevEco Studio)配置正确,所有必要的插件和工具都已安装。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部