Fluent Android CPU package build command -- split per ABI

Posted by dancahill on Tue, 11 Jan 2022 17:10:30 +0100

/ CPU /

CPU (central processing unit), system (mobile phone system, computer system...) The core of operation and control is the final execution unit of information processing and program operation. Its function is mainly to interpret hardware instructions and process data in software combined with hardware. The CPU is the core component responsible for reading instructions, decoding instructions and executing instructions. The three core components of electronic equipment are CPU, internal memory and input / output equipment. The functions of CPU (processor) mainly include processing instructions, executing operations, controlling time and processing data.

CPU has a large number of buffers and complex logic control units, so it is very good at logic control and serial operation.         

CPUGPU
Good at logic control and serial operationHe is good at large-scale concurrent computing
There are a large number of caches and complex logical control unitsThere are a large number of arithmetic units
Use CPU to do complex logic controlGPU to improve program operation speed
The amount of calculation is large, but there is no technical content, and it has to be repeated many times

/ Android ABI /

Introduction to ABI

Android mobile phone system provides application binary interface abi (Application Binary Interface) for applications running on mobile phone system. ABI includes system calls and methods of using system calls (roughly means that applications and systems need to communicate by defined functions), as well as the syntax rules of memory addresses and machine registers used. In order to avoid serious errors in the system, we need to follow the rules and conditions of system architecture and hardware architecture.

Android devices (smartphones, watches, smart TVs,...) Different CPU s support different instruction sets.

CPU and instruction set combination correspond to # exclusive application binary interface (ABI).

ABI introduction

. supported ABI

/Command -- split per ABI/

  . Packaging for application shelf

Google officials strongly recommend using app bundle s. As an old programmer, I am more skilled in compiling into apk. Domestic application markets include Huawei, Xiaomi, APP Bao, OPPO, VIVO, 360, etc, Application packages of different CPUs can be uploaded in different application markets. Because the technology of application development uses the fluent framework, the operation mode of compiling packages of different CPUs by FLUENT is as follows:

First create a fluent project

It can be created through Android Studio tool / VsCode tool / fluent command (fluent create application name)

for example : flutter create flutter_abi

Find the build under the Android project directory corresponding to the created fluent project Gradle is configured based on different abi architectures

  

flutter build apk --split-per-abi

Execute the command to open the directory where the installation package is stored after compilation (including apk of Various CPU architectures and configuration information file output-metadata.json of different apk packages)

open build/app/outputs/apk/release

Viewing any application package that supports different CPU s, I found a problem. The version code configured by the fluent project is 1. What happens after packaging

 

Find the compiled local file of the project {output metadata JSON , open and find CPU , x86, armeabi-v7a, x86_64. The version code corresponding to arm64-v8a is different from the application configuration

{
  "version": 2,
  "artifactType": {
    "type": "APK",
    "kind": "Directory"
  },
  "applicationId": "com.example.flutterabi",
  "variantName": "processReleaseResources",
  "elements": [
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "mips64"
        }
      ],
      "versionCode": 1,
      "versionName": "1.0.0",
      "outputFile": "app-mips64-release.apk"
    },
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "armeabi"
        }
      ],
      "versionCode": 1,
      "versionName": "1.0.0",
      "outputFile": "app-armeabi-release.apk"
    },
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "x86"
        }
      ],
      "versionCode": 3001,
      "versionName": "1.0.0",
      "outputFile": "app-x86-release.apk"
    },
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "armeabi-v7a"
        }
      ],
      "versionCode": 1001,
      "versionName": "1.0.0",
      "outputFile": "app-armeabi-v7a-release.apk"
    },
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "x86_64"
        }
      ],
      "versionCode": 4001,
      "versionName": "1.0.0",
      "outputFile": "app-x86_64-release.apk"
    },
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "arm64-v8a"
        }
      ],
      "versionCode": 2001,
      "versionName": "1.0.0",
      "outputFile": "app-arm64-v8a-release.apk"
    },
    {
      "type": "ONE_OF_MANY",
      "filters": [
        {
          "filterType": "ABI",
          "value": "mips"
        }
      ],
      "versionCode": 1,
      "versionName": "1.0.0",
      "outputFile": "app-mips-release.apk"
    }
  ]
}

 

Try modifying} output metadata The version code values corresponding to different CPU s in the JSON configuration file are consistent with the fluent project, and then execute the command "fluent build APK" instead of the command "fluent build APK -- split per ABI". If this command is executed, the output metadata JSON configuration changes will not take effect

flutter_abi download case

Topics: Flutter