B站视频

https://www.bilibili.com/vide...
https://www.bilibili.com/vide...

本节目标

  • 编译 build releae
  • 程序瘦身
  • 混淆程序
  • 修改程序名称
  • 制作图标
  • 制作启动画面

正文

1. APP 图标

规格说明

https://developer.android.com...

https://developer.apple.com/d...

图标尺寸

android 512x512

ios 1024x1024

在线工具

https://www.designevo.com/cn/...

flutter_launcher_icons 插件

https://pub.dev/packages/flut...

pubspec.yaml

dev_dependencies:
  # icons
  flutter_launcher_icons: ^0.7.5

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icons/logo-1024.png"

生成图标

flutter pub run flutter_launcher_icons:main

图标目录

android/app/src/main/res

ios/Runner/Assets.xcassets/AppIcon.appiconset

2. 启动图片

规格说明

https://developer.apple.com/d...

https://developer.android.com...

https://uiiiuiii.com/screen/

图片尺寸

iPhone XS Max 1242px × 2688px

android xxhdpi xhdpi

在线工具

https://hotpot.ai/icon_resizer

3. Android 发布

证书签名说明

https://developer.android.com...

生成证书

# 进入目录 android/app/
keytool -genkey -v -keystore ./key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

# 输出文件
android/app/key.jks

Gradle 配置

  • android/gradle.properties

    android.enableAapt2=false # 不检测依赖资源
  • android/key.properties

    storePassword=123456
    keyPassword=123456
    keyAlias=key
    storeFile=./key.jks
  • android/app/build.gradle

    // 定义属性读取对象,读取 android/key.properties
    def keystoreProperties = new Properties()
    def keystorePropertiesFile = rootProject.file('key.properties')
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
    }
    
    android {
        compileSdkVersion 28
    
        ...
    
        // 签名配置
        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }
    
        buildTypes {
    
            // 发布配置
            release {
                signingConfig signingConfigs.release
            }
        }
    }

修改版本号

  • pubspec.yaml
version: 1.0.0+1

修改程序名称

  • android/app/src/main/AndroidManifest.xml

        <application
            android:name="io.flutter.app.FlutterApplication"
            android:label="猫哥新闻"
            android:icon="@mipmap/launcher_icon">

设置网络权限

  • android/app/src/main/AndroidManifest.xml

        </application>
    
        <uses-permission android:name="android.permission.INTERNET" />
    </manifest>

编译打包

flutter build apk --split-per-abi

输出目录

✓ Built build/app/outputs/apk/release/app-armeabi-v7a-release.apk (7.2MB).
✓ Built build/app/outputs/apk/release/app-arm64-v8a-release.apk (7.4MB).
✓ Built build/app/outputs/apk/release/app-x86_64-release.apk (7.6MB).

混淆编译

https://github.com/flutter/fl...

  • android/gradle.properties

    extra-gen-snapshot-options=--obfuscate
  • android/proguard-rules.pro

    #Flutter Wrapper
    -dontwarn io.flutter.**
    -keep class io.flutter.app.** { *; }
    -keep class io.flutter.plugin.**  { *; }
    -keep class io.flutter.util.**  { *; }
    -keep class io.flutter.view.**  { *; }
    -keep class io.flutter.**  { *; }
    -keep class io.flutter.plugins.**  { *; }
  • android/app/build.gradle

        buildTypes {
            release {
                signingConfig signingConfigs.release
    
                minifyEnabled true  //资源压缩设置
                useProguard true    //代码压缩设置
    
                //读取代码压缩配置文件
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    
            }
        }
  • 编译
flutter build apk --split-per-abi

启动页

  • 图片

  • android/app/src/main/res/values/colors.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <color name="cyan">#deecec</color>
    </resources>
  • android/app/src/main/res/drawable/launch_background.xml

    <?xml version="1.0" encoding="utf-8"?>
    <!-- Modify this file to customize your launch splash screen -->
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:drawable="@color/cyan" />
        <item>
            <bitmap
                android:gravity="center"
                android:src="@mipmap/launch_image" />
        </item>
    </layer-list>

4. IOS 发布

启动页

修改程序名称

资源

视频

蓝湖设计稿(加微信给授权 ducafecat)

https://lanhuapp.com/url/lYuz1
密码: gSKl

蓝湖现在收费了,所以查看标记还请自己上传 xd 设计稿
商业设计稿文件不好直接分享, 可以加微信联系 ducafecat

YAPI 接口管理

http://yapi.demo.qunar.com/

代码

https://github.com/ducafecat/...

参考

https://flutter.dev/docs/depl...

https://flutter.dev/docs/depl...

https://flutter.dev/docs/depl...

https://github.com/flutter/fl...

https://pub.dev/packages/flut...

https://developer.android.com...

https://developer.apple.com/d...

https://developer.apple.com/d...

https://developer.android.com...

https://uiiiuiii.com/screen/

VSCode 插件


独立开发者_猫哥
666 声望126 粉丝