当前位置:网站首页>The gradle configuration supports the upgrade of 64 bit architecture of Xiaomi, oppo, vivo and other app stores
The gradle configuration supports the upgrade of 64 bit architecture of Xiaomi, oppo, vivo and other app stores
2022-06-25 09:52:00 【seevc】
One 、 reason
Recently received an upgrade from Xiaomi and other app stores 64 Notification of bit architecture , The general content is as follows : For better promotion APP Performance experience , Reduce APP Power consumption impact , Xiaomi app store and OPPO The app store 、vivo App stores jointly promote the domestic android ecosystem 64 Bit architecture upgrade support . The industry adaptation rhythm is as follows :
2021 year 12 End of month : Existing and new applications / game , You need to upload a file containing 64 The study of the inclusion APK package ( Support double package in shelf , and 64 Bit compatible 32 Two forms of bit , No longer receive only support 32 Bit APK package )2022 year 8 End of month : Hardware support 64 A system of , Will receive only those with 64 A version of the APK package2023 end of the year : The hardware will only support 64 position APK,32 Bit application cannot run on the terminal
After receiving the notification, I checked my app and found that only 32 An architecture (armabi, In order to reduce the Apk Inclusion size ). Since the major app stores have mandatory requirements for this , So we should aim at 64 The bit architecture is out of the package .
### Two 、 Two kinds of schemes
From the app store, you can see that uploading is only supported 64 Bit structured APK package , So consider supporting 32 Bit and 64 Bits packed separately , This will ensure APK size , And meet the needs .
After research, it is found that there are two ways to realize .
##### Scheme 1
stay android Add... Under the code block splits Code block , Then add abi Code block and configure to support ABI list .
Let's take an example :
andoird{
...
splits{
// Press ABI Configure multiple APK.
abi {
enable true
reset()
include "armeabi-v7a", "arm64-v8a"
universalApk false
}
}
}
Now let's explain the meaning of the related configuration attributes .
stay Gradle DSL Press ABI Configure multiple APK, There are several properties :
enable, Whether to enable the... According to the configuration ABI package , Default false, That is, do not open ;exclude, Appoint Gradle Which... Should not be targeted ABI Generate separate APK, Configure... As a comma separated list , There's no need to be withreset()、includeSimultaneous configuration ;reset(), Clear the default ABI list , Only with include Elements are used in combination , To specify what you want to add ABI;include, Packaging should support ABI list , Specify... As a comma separated list Gradle What should be targeted ABI Generate APK. Only with reset() Use a combination of , To specify the exact ABI list ;universalApk, Whether it is necessary to type an include include All configured ABI Generic package for , The default is false, If set to true, Then you will press ABI Generated APK outside ,Gradle It will also generate a generic APK
About reset() Important details of stay Android Plugin for Gradle 3.1.0 And above versions are no longer supported ABI Yes :mips、mips64 and armeabi, Because in NDK R17 Version and above no longer support these ABI. Higher version Gradle The plug-in supports by default ABI by :armeabi-v7a、arm64-v8a、x86、x86_64.reset() Remove the ABI The list is just these , So when not in use reset() when , These architectures are included by default .
The following is to support :armeabi-v7a、 arm64-v8a The configuration mode of the instance
use exclude The way
andoird{
...
splits{
// Press ABI Configure multiple APK.
abi {
enable true
// According to the default supported abi, The following two items are excluded , That's all armeabi-v7a、arm64-v8a
exclude "x86", "x86_64"
universalApk false
}
}
}
use reset() and include combination
andoird{
...
splits{
// Press ABI Configure multiple APK.
abi {
enable true
reset()
include "armeabi-v7a", "arm64-v8a"
universalApk false
}
}
}
use Build -> Generate signed Bundle/APK Or run assembleRelease pack , You can perform a packaging operation to automatically generate multiple Apk package .
That's it. I'll finish the program , Doesn't it look very simple . So let's move on .
##### Option two
Refer to subcontracting to be familiar with Android Developers should think about it very quickly productFlavors, you 're right , The second option is to use productFlavors Realized .
adopt productFlavors The code block can realize multi-dimensional variants of the product , such as :vip He Fei vip package 、 The version number is different , Channel package, etc
It's described in the official documents :“ In some cases , You may want to combine the configurations of multiple product variants . for example , You may want to base your API Grade “full” and “demo” Product variants create different configurations . So , You can use Android Plugin for Gradle Create multiple groups of product variants as variant dimensions . When building applications ,Gradle The product variant configuration in each variant dimension you define and build Type configurations are grouped together , To create the final build variant .Gradle Product variants belonging to the same variant dimension will not be combined .”
The following still supports armeabi-v7a and arm64-v8a For instance , First look at the configuration instance :
android{
...
flavorDimensions "teacher"
productFlavors{
armabi_v7a{
ndk {
abiFilters "armeabi-v7a"
}
dimension "teacher"
}
arm64_v8a{
ndk {
abiFilters "arm64-v8a"
}
dimension "teacher"
}
}
}
Configuration related attribute interpretation
flavorDimensions, Define product dimensions , Multiple dimensions can be defined , Separate with commas , The configured value corresponds to productFlavors Medium dimension Property value ;- among
armeabi_v7aandarm64_v8aNames can be defined by themselves ; ndk, The configuration code block is the package to include ABI;abiFilters, Define what packaging supports arm framework , Support configuration of multiple , Separate with commas , Such as :"armeabi-v7a","x86"dimension, Dimension of the product , Value has to be withflavorDimensionsThe values configured in are consistent , Otherwise, such errors will occur :The flavor 'flavor_name' is not assigned to a flavor dimension
explain
When configuring packaging in this way , It needs to be packed one by one , as follows :Build->Generate signed Bundle/APK Schematic diagram of mode packaging :
perhaps Gradle perform Task The way :
3、 ... and 、 Comparison of the two schemes
| The way | advantage | shortcoming |
|---|---|---|
| splits | Simple configuration , A single package can generate multiple APK | Unable to support ABI The way of combination , Such as :armeabi-v7a and x86 |
| productFlavors | Support multiple ABI Pack together , Relatively flexible | 1. comparison splits The way is a little complicated , Need to pass through flavorDimensions Define dimensions 2. Packaging is a little complicated , It is not possible to generate multiple by packaging at once APK |
Through comparison, we found that :
1. if APP Only one kind of CPU framework , Then mode 1 is more appropriate ;
2. if APP At the same time, support arm and x86 framework , Then mode 2 is more appropriate ;
### Reference resources Android Official documents
in the light of ABI Configure multiple APK
Combine multiple product variants and variant dimensions
边栏推荐
- Arduino bootloader burning summary
- 请问在手机上开户股票,还是去证券公司开户安全?
- ‘Flutter/Flutter. h‘ file not found
- Voiceprint Technology (I): the past and present life of voiceprint Technology
- Wallys/MULTI-FUNCTION IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL
- [competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition
- Wallys/MULTI-FUNCTION IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL
- Chitubox micromake l3+ slicing software configuration correspondence
- Grabcut image segmentation in opencv
- Can two Mitsubishi PLC adopt bcnettcp protocol to realize wireless communication of network interface?
猜你喜欢

SQL高级

Remove the mosaic, there's a way, attached with the running tutorial

Online notes on Mathematics for postgraduate entrance examination (9): a series of courses on probability theory and mathematical statistics

Reasons for Meiye to choose membership system

Prediction of pumpkin price based on BP neural network

2021mathorcupc topic optimal design of heat dissipation for submarine data center

Japanese online notes for postgraduate entrance examination (9): composition template

CyCa children's physical etiquette Yueqing City training results assessment successfully concluded
![[buuctf.reverse] 117-120](/img/6c/8a90fff2bd46f1494a9bd9c77eeafc.png)
[buuctf.reverse] 117-120

Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial
随机推荐
Fluent creates, reads and writes JSON files
Grabcut image segmentation in opencv
Neo4jdesktop (neo4j desktop version) configures auto start (boot auto start)
Reasons for Meiye to choose membership system
将jar包注册为服务,实现开机自动启动
Online notes on Mathematics for postgraduate entrance examination (9): a series of courses on probability theory and mathematical statistics
x86电脑上下载debian的arm64的包
What should be paid attention to in PMP examination?
Match a mobile number from a large number of mobile numbers
Study on correlation of pumpkin price and design of price prediction model based on BP neural network
STM32 receives data by using idle interrupt of serial port
C语言刷题随记 —— 猴子吃桃
Voiceprint Technology (VI): other applications of voiceprint Technology
Question B of the East China Cup: how to establish a population immune barrier against novel coronavirus?
[learn C from me and master the key to programming] insertion sort of eight sorts
[buuctf.reverse] 117-120
Notes on writing questions in C language -- monkeys eat peaches
Voiceprint Technology (V): voiceprint segmentation and clustering technology
Japanese online notes for postgraduate entrance examination (9): composition template
Is GF Securities reliable? Is it legal? Is it safe to open a stock account?