[英]When I wnat to get package flutter it show me HTTP error 403: Forbidden
I am working on flutter project in Intellij Idea.我正在 Intellij Idea 中从事 flutter 项目。 when I want to add a package in pubspec.yaml, it leads to below errror:
当我想在 pubspec.yaml 中添加 package 时,它会导致以下错误:
HTTP error 403: Forbidden
package:pub/src/http.dart 218:5 _ThrowingClient.send
===== asynchronous gap ===========================
package:http_throttle/http_throttle.dart 33:31 ThrottleClient.send
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 322:37 BoundHostedSource._download
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 217:13 BoundHostedSource.downloadToSystemCache
===== asynchronous gap ===========================
package:pub/src/entrypoint.dart 374:48 Entrypoint._get.<fn>
===== asynchronous gap ===========================
dart:async runZoned
package:pub/src/http.dart 272:10 withDependencyType
package:pub/src/entrypoint.dart 370:12 Entrypoint._get
dart:async Future.wait
package:pub/src/entrypoint.dart 231:18 Entrypoint.acquireDependencies
dart:async _completeOnAsyncReturn
package:pub/src/solver/version_solver.dart VersionSolver.solve
dart:async _completeOnAsyncReturn
package:pub/src/solver/version_solver.dart VersionSolver._result
This is an unexpected error. Please run
pub --trace '--verbosity=warning' get --no-precompile
and include the logs in an issue on https://github.com/dart-lang/pub/issues/new
I have tried using vpn and without vpn both of them doesnt work.我试过使用 vpn 和没有 vpn 两者都不起作用。 Also, when i add some common package such as provider or http, its fine.
此外,当我添加一些常见的 package(例如提供商或 http)时,它很好。
This is my code:这是我的代码:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
provider: ^3.2.0
http: ^0.12.0+2
font_awesome_flutter: ^8.5.0
flutter_rating_bar: ^3.0.0
my flutter sdk version: flutter_windows_v1.9.1+hotfix.6-stable_3我的 flutter sdk 版本:flutter_windows_v1.9.1+hotfix.6-stable_3
Could you please help me?请你帮助我好吗?
Thanks in advance提前致谢
same problem happened for me so i just did同样的问题发生在我身上所以我就做了
1:flutter clean 1:flutter 清洁
2:use 2 vpn at same time 2:同时使用2个VPN
this problem happened because of your connection;)这个问题是由于您的连接而发生的;)
It may solve your problem:它可能会解决您的问题:
I had exactly the same problem and changed a few VPN , but it was still a problem and did not work我遇到了完全相同的问题并更改了几个VPN ,但它仍然是一个问题并且没有用
I used a service that changed DNS to fix the problem of sanctions and the problem was solved我用了一个改DNS的服务来修复sanctions的问题,问题解决了
After hours of trying to solve this problem, I finally found a solution.经过数小时的尝试解决这个问题,我终于找到了解决方案。
First, you have to delete all the packages of project from pubspec.yaml file (you can comment these lines, so you don't forget what's packages used)首先,你必须从pubspec.yaml文件中删除项目的所有包(你可以注释这些行,这样你就不会忘记使用了什么包)
then add all the packages to the project from cmd with this command:然后使用以下命令将所有包从cmd添加到项目中:
flutter pub add <package_name>
Make sure to use cmd, not powershell.确保使用 cmd,而不是 powershell。
I hope this solution works for you.我希望这个解决方案对你有用。
It often related to VPN connection.它通常与 VPN 连接有关。 before running
flutter pub get
, being sure that you can open https://developer.android.com/
site.在运行
flutter pub get
之前,请确保您可以打开https://developer.android.com/
站点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.