【错误记录】发布 Flutter 插件包报错 ( Failed to upload the package.pub finished with exit cod

文章目录

  • 一、报错信息
  • 二、解决方案

一、报错信息

发布插件包时,确认发布并校验Google账号后出现以下报错:

vbnet 复制代码
Failed to upload the package.
pub finished with exit code 1

完整报错信息:

vbnet 复制代码
D:\002_Project\002_Android_Learn\flutter_package>flutter packages pub publish
Publishing flutter_package 0.0.1 to https://pub.flutter-io.cn:
|-- .gitignore
|-- .metadata
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- lib
|   '-- flutter_package.dart
|-- pubspec.yaml
'-- test
    '-- flutter_package_test.dart

Publishing is forever; packages cannot be unpublished.
Policy details are available at https://pub.dev/policy

Do you want to publish flutter_package 0.0.1 (y/N)? y
Uploading...
Failed to upload the package.
pub finished with exit code 1

使用flutter packages pub publish -v命令可以获取更详细的日志信息:

vbnet 复制代码
FINE: Uploading finished (0.642s).
FINE: Saving OAuth2 credentials.
IO  : Writing 1381 characters to text file D:\001_Develop\010_Flutter\flutter_windows_2.2.3-stable\flutter\.pub-cache\credentials.json.
ERR : Failed to upload the package.
FINE: Exception type: ApplicationException
...

二、解决方案

这个问题通常是由于设置了Flutter镜像导致的。很多开发者在使用appuploader等iOS开发工具时也会遇到类似的配置问题,解决方案如下:

  1. 检查环境变量中是否设置了以下镜像:

    arduino 复制代码
    PUB_HOSTED_URL : https://pub.flutter-io.cn 
    FLUTTER_STORAGE_BASE_URL : https://storage.flutter-io.cn
  2. 从环境变量中移除上述两个镜像

  3. 使用以下命令向Flutter中央仓库推送Dart包:

    ini 复制代码
    flutter packages pub publish --server=https://pub.dartlang.org

成功上传后会显示:

go 复制代码
D:\002_Project\002_Android_Learn\flutter_package>flutter packages pub publish --server=https://pub.dartlang.org
Publishing flutter_package_first_demo 0.0.1 to https://pub.dartlang.org:
...
Successfully uploaded package.

对于iOS开发者来说,类似的问题在使用appuploader等工具上传应用时也可能遇到。建议在上传前仔细检查网络配置和证书设置,确保开发环境配置正确。

相关推荐
程序员海军8 小时前
用了两年多 GPT,我最近开始换模型了,还折腾了个求职避坑 Agent
前端·人工智能·后端
码士集团小青8 小时前
SpringBoot 集成缓存性能之王 Caffeine
spring boot·后端·缓存
excel10 小时前
IndexNow:让搜索引擎更快发现网站更新的主动通知协议
前端·后端·架构
Json____10 小时前
用 FastAPI + Vue3 打造一套完整的在线考试系统:从组卷到阅卷的业务闭环实践
后端·node.js·fastapi·it学习·wwwoop.com
小灰灰搞电子11 小时前
Rust+Slint 实现FTP客户端调试助手源码分享
开发语言·后端·rust
专业程序开发源12 小时前
springboot欧缇蔓月子中心管理系统82697-计算机课程设计、毕业设计
java·spring boot·后端·python·spring·django·课程设计
卷无止境12 小时前
面向arm64桌面客户端开发全景:语言、框架与生态
后端·python
IT_陈寒13 小时前
JavaScript的闭包陷阱,这个坑我躺了三天才爬出来
前端·人工智能·后端
用户83562907805113 小时前
如何使用 Python 对 Excel 数据进行分组和分级显示
后端·python
vx_Biye_Design13 小时前
django房屋租赁推荐系统78455-计算机课程设计、毕业设计
vue.js·spring boot·后端·python·django·课程设计·express