前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Flutter macOS Android打包

Flutter macOS Android打包

作者头像
大话swift
发布2019-07-04 11:12:26
8170
发布2019-07-04 11:12:26
举报
文章被收录于专栏:大话swift大话swift大话swift

对于macOS用户使用flutter build apk打包可为曲折,官方只给出了Android正常的配置流程,但是macOS用户是不行滴---需要申请系统的访问权限授权

GitHub地址:https://github.com/skeyboy/less_flutter

视频内容
  1. 简略的Android Studio配置(默认你的签名文件已经设置完成) 防止key.properties文件

配置gradle

配置脚本执行是申请macOS的系统权限参考文章

  1. 打开keychain app, 选中密码,点击底部toolbar的+

2. 设置对应的信息

密钥项目名称:随意填写,就是一个名称

账户名称:可以打开终端输入```whoami```可以查看对应用户

3. gradle配脚本

def getPassword(String currentUser, String keyChain) {

def stdout = new ByteArrayOutputStream()

def stderr = new ByteArrayOutputStream()

exec {

commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w'

standardOutput = stdout

errorOutput = stderr

ignoreExitValue true

}

//noinspection GroovyAssignabilityCheck

stdout.toString().trim()

}

def getWhoami(){

def stdout = new ByteArrayOutputStream()

def stderr = new ByteArrayOutputStream()

exec {

commandLine 'whoami'

standardOutput = stdout

errorOutput = stderr

ignoreExitValue true

}

//noinspection GroovyAssignabilityCheck

stdout.toString().trim()

}

//def pass = getPassword("YOUR_USER_NAME","android_keystore") //终端中 whoami 查看YOUR_USER_NAME android_keystore你在密钥串中设置的名称

def pass = getPassword(getWhoami(),"les01_flutter")

最终配置

def getPassword(String currentUser, String keyChain) {

def stdout = new ByteArrayOutputStream()

def stderr = new ByteArrayOutputStream()

exec {

commandLine 'security', '-q', 'find-generic-password', '-a', currentUser, '-s', keyChain, '-w'

standardOutput = stdout

errorOutput = stderr

ignoreExitValue true

}

//noinspection GroovyAssignabilityCheck

stdout.toString().trim()

}

def getWhoami(){

def stdout = new ByteArrayOutputStream()

def stderr = new ByteArrayOutputStream()

exec {

commandLine 'whoami'

standardOutput = stdout

errorOutput = stderr

ignoreExitValue true

}

//noinspection GroovyAssignabilityCheck

stdout.toString().trim()

}

//def pass = getPassword("YOUR_USER_NAME","android_keystore") //终端中 whoami 查看YOUR_USER_NAME android_keystore你在密钥串中设置的名称

def pass = getPassword(getWhoami(),"les01_flutter")

def keystorePropertiesFile = rootProject.file("key.properties")

def keystoreProperties = new Properties()

keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {

compileSdkVersion 27

lintOptions {

disable 'InvalidPackage'

}

defaultConfig {

// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).

applicationId "com.xiangshike.les01hello"

minSdkVersion 16

targetSdkVersion 27

versionCode 1

versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

signingConfigs {

release {

keyAlias keystoreProperties['keyAlias']

storeFile file(keystoreProperties['storeFile'])

/*

//windows用户

keyPassword keystoreProperties['keyPassword']

storePassword keystoreProperties['storePassword']

*/

storePassword pass // Change this

keyPassword keystoreProperties['keyPassword'] // Change this

}

}

buildTypes {

release {

// TODO: Add your own signing config for the release build.

// Signing with the debug keys for now, so `flutter run --release` works.

// signingConfig signingConfigs.debug

signingConfig signingConfigs.release

}

}

}

打包:

flutter build apk --debug

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-02-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 大话swift 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档