当前位置:网站首页>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
边栏推荐
- I put a two-dimensional code with rainbow candy
- 2022 postgraduate entrance examination experience post -- Alibaba Business School of Hangzhou Normal University -- management science and Engineering (including the recommendation of books and course
- 在指南针上面开股票账户好不好,安不安全?
- Remittance international empowers cross-border e-commerce: to be a compliant cross-border payment platform!
- 纳米数据世界杯数据接口,中超数据,体育数据比分,世界杯赛程api,足球比赛实时数据接口
- Why should the terminal retail industry choose the member management system
- Rxjs TakeUntil 操作符的学习笔记
- Match a mobile number from a large number of mobile numbers
- Tiktok brand goes to sea: both exposure and transformation are required. What are the skills of information flow advertising?
- [IOU] intersection over union
猜你喜欢
![[learn C from me and master the key to programming] insertion sort of eight sorts](/img/2c/22e065390464ed5cd1056346d46573.jpg)
[learn C from me and master the key to programming] insertion sort of eight sorts

SQL高级

Etcd教程 — 第四章 Etcd集群安全配置

Notes on writing questions in C language -- monkeys eat peaches

x86的编码格式

Simple waterfall effect
![[2020 cloud development + source code] 30 minutes to create and launch wechat applet practical project | zero cost | cloud database | cloud function](/img/89/39851fee714be872a599ad4ddd4852.jpg)
[2020 cloud development + source code] 30 minutes to create and launch wechat applet practical project | zero cost | cloud database | cloud function
![[competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)](/img/f3/a8414635ad39ad405864f5fcf66d6d.jpg)
[competition -kab micro entrepreneurship competition] KAB National College Students' micro entrepreneurship action participation experience sharing (including the idea of writing the application form)

Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.

Vscode attempted to write the procedure to a pipeline that does not exist
随机推荐
[Ruby on rails full stack course] course directory
[MySQL learning notes 22] index
【mysql学习笔记22】索引
Neat Syntax Design of an ETL Language (Part 2)
Wechat official account can reply messages normally, but it still prompts that the service provided by the official account has failed. Please try again later
Encoding format for x86
x86的编码格式
Flutter replaces the default icon of Gaud positioning
瑞吉外卖项目(二)
Neo4jdesktop (neo4j desktop version) configures auto start (boot auto start)
Compare and explain common i/o models
Voiceprint Technology (VI): other applications of voiceprint Technology
vscode试图过程写入管道不存在
JS tool function, self encapsulating a throttling function
pmp考试题型需要注意哪些?
STM32 receives data by using idle interrupt of serial port
Online notes on Mathematics for postgraduate entrance examination (8): Kego equations, eigenvalues and eigenvectors, similarity matrix, quadratic series courses
How do dating applets make millions a year? What is the profit model?
Voiceprint Technology (I): the past and present life of voiceprint Technology
The way that flutter makes the keyboard disappear (forwarding from the dependent window)