flutter开发环境搭建及apk打包

Windows  => flutter (默认安装了git)
1.官网下载Flutter安装包 解压到你的路径(如:C:\src\flutter;注意,不要将flutter安装到需要一些高权限的路径如C:\Program Files\)。
2.配置flutter环境变量或host
a.Path:	D:\flutter\bin;  
b.FLUTTER_STORAGE_BASE_URL:  https://storage.flutter-io.cn
c.PUB_HOSTED_URL:  https://pub.flutter-io.cn
d.Host  =>	C:\Windows\System32\drivers\etc\hosts
https://pub.flutter-io.cn PUB_HOSTED_URL
https://storage.flutter-io.cn FLUTTER_STORAGE_BASE_URL
3.下载安装
a.Android Studio => https://developer.android.google.cn/studio
b.安装插件flutter => file > settings ( dart会自动安装 )
c.创建模拟器 ( 注意版本号 android 8.0 已下 否则可能跑不起来)
4.创建 flutter 项目
5.打包APK 
参考:https://blog.csdn.net/qq_30359677/article/details/81387183
a.配置keytool环境变量 
path => C:\Program Files\Android\Android Studio\jre\jre\bin (Android Studio安装目录keytool所在路径)
b.terminal执行下列命令
keytool -genkey -v -keystore D:/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key	(D:/key.jks  生成签名存放路; key 密钥名)
c.在android下 创建一个key.properties文件
 #创建KEY时输入的 密钥库 密码
storePassword=123456
#创建KEY时输入的 密钥 密码
keyPassword=123456
#密钥名称
keyAlias=key
#签名的存放路径
storeFile=E:/AndriodStudioProject/key.jks

d.在/android/app/build.gradle文件,在 android { 这一行前面,加入如下代码:
//找到你的key.properties文件内容
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
e.同d 修改buildTypes
signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
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
    }
}

f.添加权限
1.andriod/app/src/main/AndroidManifest.xml
2.andriod/app/src/profile/AndroidManifest.xml
在上面两文件加上如下权限代码 (网络请求)





g.执行 flutter build apk => build\app\outputs\apk\release (生成路径)

 

你可能感兴趣的:(flutter开发环境搭建及apk打包)