[Flutter] Android Studio 三步發佈Flutter插件

1 檢查配置

首先配置 pubspec.yaml,pubspec 裏除了插件的依賴,能夠根據須要,把這些補上:git

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裏就好。github

2 檢查插件

flutter packages pub publish --dry-run
複製代碼

Terminal中輸入以上命令,Terminal中顯示Package has 0 warnings. 則無問題,不然根據提示修改便可。web

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可能未包含。bash

受權完後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中輸入如下命令,從新執行本步驟便可。ui

//我這裏是SS,不一樣的工具可能不同。
set http_proxy=http://127.0.0.1:1080
set https_proxy=https://127.0.0.1:1080
複製代碼
相關文章
相關標籤/搜索