[Flutter] Android Studio 三步发布Flutter插件

3,729 阅读1分钟

1 检查配置

首先配置 pubspec.yaml,pubspec 里除了插件的依赖,可以根据需要,把这些补上:

name: flutter_plugin_20181225
description: A new Flutter plugin
version: 0.0.1
author: Joker <wrap****@gmail.com>
homepage: https://github.com/joker-fu

environment:
  sdk: ">=1.19.0 <2.0.0"

发布到 Pub 上需要包含一个LICENSE, 我是把代码传到github生成一个,复制到根目录LICENSE里就好。

2 检查插件

flutter packages pub publish --dry-run

Terminal中输入以上命令,Terminal中显示Package has 0 warnings. 则无问题,否则根据提示修改即可。

3 发布插件(注意 番羽 墙)

flutter packages pub publish

Terminal中输入以上命令,第一次发布会出现以下授权界面,复制链接到浏览器授权即可

Looks great! Are you ready to upload your package (y/n)? y
Pub needs your authorization to upload packages on your behalf.
In a web browser, go to https://accounts.google.com/o/oauth2/auth?*******userinfo.email
Then click "Allow access".

注意: 链接到 .email 结束,直接点击userinfo.email可能未包含。

授权完后Android Studio自动开始上传插件,当Terminal中显示Package has 0 warnings. 则无问题,否则根据提示修改即可。

Waiting for your authorization...
Authorization received, processing...
It looks like accounts.google.com is having some trouble.
Pub will wait for a while before trying to connect again.
OS Error: Operation timed out, errno = 60, address = accounts.google.com, port = 53481
pub finished with exit code 69

出现上面这个证明还要 番羽 墙,这时在Android Studio中系统设置的配置的HTTP Proxy可能你CHeck connection是有效的,但是还是会出现以上问题,需要在Terminal中输入以下命令,重新执行本步骤即可。

//我这里是SS,不同的工具可能不一样。
set http_proxy=http://127.0.0.1:1080
set https_proxy=https://127.0.0.1:1080