当前位置:网站首页>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
边栏推荐
- Voiceprint Technology (V): voiceprint segmentation and clustering technology
- Voiceprint Technology (I): the past and present life of voiceprint Technology
- Nano data World Cup data interface, CSL data, sports data score, world cup schedule API, real-time data interface of football match
- 富时A50开户什么地方安全
- Tiktok brand goes to sea: both exposure and transformation are required. What are the skills of information flow advertising?
- How do dating applets make millions a year? What is the profit model?
- CyCa children's physical etiquette Yueqing City training results assessment successfully concluded
- Solution to the problem of repeated startup of esp8266
- Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial
- Lvs-dr mode single network segment case
猜你喜欢
![[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate](/img/75/a06e20b4394579cbd9f6d3a075907a.jpg)
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate

Data-driven anomaly detection and early warning of 21 May Day C

Reza RA series - development environment construction

x86电脑上下载debian的arm64的包

Register the jar package as a service to realize automatic startup after startup

Chitubox micromake l3+ slicing software configuration correspondence

Cassava tree disease recognition based on vgg16 image classification

Tiktok brand goes to sea: both exposure and transformation are required. What are the skills of information flow advertising?

Puzzle (019.2) hexagonal lock

Why should the terminal retail industry choose the member management system
随机推荐
Puzzle (019.2) hexagonal lock
手机办理长城证券开户靠谱安全吗?
2022 meisai question a idea sharing
Learning notes of rxjs takeuntil operator
Data-driven anomaly detection and early warning of 21 May Day C
Ruiji takeout project (II)
Compare and explain common i/o models
Fcpx quickly add subtitles | Final Cut Pro import fcpxml subtitle file does not match the video time? I got it in code
JS tool function, self encapsulating a throttling function
Voiceprint Technology (III): voiceprint recognition technology
[buuctf.reverse] 121-125
How much money have I made by sticking to fixed investment for 3 years?
Is it safe to open an account on the compass?
2台三菱PLC走BCNetTCP协议,能否实现网口无线通讯?
The problem of wirengpi program running permission
[buuctf.reverse] 117-120
Data-driven anomaly detection and early warning of item C in the May 1st mathematical modeling competition in 2021
oracle 函数 触发器
Etcd tutorial - Chapter 4 etcd cluster security configuration
Is it harder to find a job in 2020? Do a good job in these four aspects and find a good job with high salary