The Flutter Mac packs APK and IPA

1. Pack APK

  1. Configure the APP name and icon

/ android/app/SRC/main/res/will see a lot of mipmap – folder named for the prefix, namely app Icon for the changes; / android/app/SRC/main/AndroidManifest. XML in AndroidManifest. Find application in XML tags

Android :label=" @mipmap "android:icon="@mipmap ">Copy the code
  1. Application signature

On the macOS terminal system, run the following command

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Copy the code

If you need to install the Java SDK, download it from the official website.

After that, enter various passwords, passwords, names, regions, etc

  1. Create a key. The properties

In the /android/key.properties path, manually create the key.properties file and paste the following code

StorePassword = 123456 123456 keyAlias keyPassword = = key storeFile = / Users/minjinglin/key JKS / / here instead of their ownCopy the code
  1. Configure the signature in build.gradle

/ android/app/build. Gradle editing files to configure the signature for the app:

Find the android{} code block and add the following code:

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
Copy the code

Replace the buildTypes code block with the following:

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
Copy the code
  1. Generated APK

Terminal operation

flutter build apk
Copy the code

Can produce apk, location in the/build/app/outputs/flutter – apk/app – the apk

Note: The Flutter package release android APK package cannot be installed on the real machine

In this file, Android \app\ SRC \main\ androidmanifest.xml, manifest add this code:

<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />Copy the code

Package IPA

Packaging ipA is relatively simple, with less command modification except that it takes a little time. The prerequisite is that your certificate is configured in advance.

  1. Select the iOS directory and open the.xcworkspace file with Xcode;

  2. Configure the APP name and icon

3. Click Archive of Product and package IPA as prompted

I’m not perfect. But I keep trying.