In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Android several multi-channel packaging steps are how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
1. What is multi-channel packaging
There may be different statistical requirements in different application markets, and it is necessary to release an installation package for each application market, which leads to the multi-channel packaging of Android. Add different logos to the installation package to distinguish each channel and facilitate the statistics of app in the market.
2. Several ways of packing
Friendly League UMeng Android Studio has its own Meituan Walle
3. Start using
3.1Friendship UMeng
Step 1: add to AndroidManifest
Step 2: add to build.gradle, and baidu {} is the abbreviation of the specified channel name.
Build {. ProductFlavors {baidu {} xiaomi {} qihu360 {} yingyongbao {} huawei {} productFlavors.all {flavor-> flavor.manifestPlaceholders = [UMENG_CHANNEL: name]}}
Step 3: set the output APK name
Android Studio version 2.3:
Build {. ApplicationVariants.all {variant-> variant.outputs.each {output-> def outputFile = output.outputFile if (outputFile! = null & & outputFile.name.endsWith ('.apk')) {def fileName = "driver_$ {variant.productFlavors [0] .name} _ v$ {defaultConfig.versionName} .apk" output.outputFile = new File (outputFile.parent, fileName)}}
Android Studio version 3.0:
Build {. ApplicationVariants.all {variant-> variant.outputs.all {outputFileName = "driver_$ {variant.productFlavors [0] .name} _ v$ {variant.versionName} .apk"}
If the following error occurs after Gradle
The dimension that needs to be configured with flavor dimension is the version number, so that the dimensions are all unified.
Build {. DefaultConfig {. FlavorDimensions "versionCode"}}
Step 4: compile and package
Build-Generate Signed Bundle or APK-Select Release or Debug
3.2 Android Studio comes with
Android Studio polymorphic packaging is the same as that of friends, but the name in the tag can be defined by itself and is not limited to "UMENG_CHANNEL".
3.3 Meituan Walle
Step 1: configure the root build.gradle
Buildscript {dependencies {classpath 'com.mcxiaoke.packer-ng:plugin:2.0.1'}}
Step 2: configure App build.gradle
Apply plugin: 'packer'dependencies {.implementation' com.mcxiaoke.packer-ng:helper:2.0.1'}
Step 3: plug-in configuration
Build {. Packer {archiveNameFormat ='${buildType}-v$ {versionName}-${channel}'/ / define output APK name archiveOutput = new File (project.rootProject.buildDir, "apks") / / set APK output directory channelFile = new File (project.rootDir, "channel.txt") / / add Channel profile}}
Step 4: create a new channel profile channel.txt
Create a new channel.txt file under the root of the project, as shown in the figure
The content of the file is the channel name, which requires that there must be one channel per line.
Step 5: compile and package
Use the Terminal command:
Gradlew clean apkRelease
For more information, please see [Meituan's official document for Multi-Channel Packaging] (https://github.com/mcxiaoke/packer-ng-plugin))
4. Obtain channel information
1. Friendly League and Android Studio acquisition methods
By reading tags in AndroidManifest
Private String getChannel () {try {PackageManager pm = getPackageManager (); ApplicationInfo appInfo = pm.getApplicationInfo (getPackageName (), PackageManager.GET_META_DATA); String channel = appInfo.metaData.getString (key); / / key is name if (! TextUtils.isEmpty (channel)) {return channel;}} catch (Exception e) {e.printStackTrace ();} return null;}
2. How to obtain Meituan's Walle
Meituan integrated with its own acquisition method
Private String getChannel () {try {PackageManager pm = getPackageManager (); ApplicationInfo appInfo = pm.getApplicationInfo (getPackageName (), PackageManager.GET_META_DATA); String channel = appInfo.metaData.getString (key); / / key is name if (! TextUtils.isEmpty (channel)) {return channel;}} catch (Exception e) {e.printStackTrace ();} return null;}
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.