错误记录发布 Flutter 插件包报错 ( Failed to upload the package.pub finished with exit code 1 )

Posted 韩曙亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误记录发布 Flutter 插件包报错 ( Failed to upload the package.pub finished with exit code 1 )相关的知识,希望对你有一定的参考价值。





一、报错信息



发布插件包 , 确认发布 , 校验了 Google 账号 , 之后报错如下 :

Failed to upload the package.
pub finished with exit code 1

完整报错信息 :

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

命令 , 执行后 , 会打印出更加详细的日志信息 ;

详细报错信息 :

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
FINE: package:pub/src/utils.dart 512:5                                                      fail
    | package:pub/src/command/lish.dart 109:9                                               LishCommand._publish
    | ===== asynchronous gap ===========================
    | dart:async                                                                            Future.catchError
    | package:pub/src/utils.dart 113:52                                                     captureErrors.wrappedCallback
    | package:stack_trace                                                                   Chain.capture
    | package:pub/src/utils.dart 126:11                                                     captureErrors
    | package:pub/src/command.dart 164:13                                                   PubCommand.run
    | package:args/command_runner.dart 196:27                                               CommandRunner.runCommand
    | package:pub/src/command_runner.dart 150:26                                            PubCommandRunner.runCommand
    | package:pub/src/command_runner.dart 138:18                                            PubCommandRunner.run
    | C:\\b\\s\\w\\ir\\cache\\builder\\src\\third_party\\dart\\third_party\\pkg\\pub\\bin\\pub.dart 9:48  main
[+11046 ms] "flutter pub" took 11,127ms.
[   +4 ms] pub finished with exit code 1
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:368:7)
           <asynchronous suspension>
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>


[ +258 ms] ensureAnalyticsSent: 257ms
[   +3 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1

D:\\002_Project\\002_Android_Learn\\flutter_package>





二、解决方案



由于设置了 Flutter 镜像导致 ;

PUB_HOSTED_URL : https://pub.flutter-io.cn
FLUTTER_STORAGE_BASE_URL : https://storage.flutter-io.cn

从环境变量中移除上述两个镜像 ;


再使用如下命令 , 向 Flutter 中央仓库推送 Dart 包 ;

flutter packages pub publish --server=https://pub.dartlang.org

终于上传成功了 :

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:
|-- .gitignore
|-- .metadata
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- lib
|   '-- flutter_package_first_demo.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_first_demo 0.0.1 (y/N)? y
Uploading...
Successfully uploaded package.

D:\\002_Project\\002_Android_Learn\\flutter_package>

以上是关于错误记录发布 Flutter 插件包报错 ( Failed to upload the package.pub finished with exit code 1 )的主要内容,如果未能解决你的问题,请参考以下文章

错误记录发布 Flutter 插件包报错 ( ‘gmail.com‘ has insufficient permissions to upload new versions of package)(代

错误记录安装 Visual Studio 2013 中文语言包报错 ( 需要 Microsoft Visual Studio Test Agent , 但此计算机上并为安装它 )

Python 学习记录Pycharm导入第三方包报错问题……ValueError: check_hostname requires server_hostname

eclipse maven 包报错怎么解决

微软SSIS部署抽取数据的包报错

Spring boot 打包为war包报错:提示缺少web.xml