├── .gitignore ├── .idea ├── compiler.xml ├── gradle.xml ├── misc.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── baidu │ └── release │ │ ├── app-baidu-release.apk │ │ └── output-metadata.json ├── build.gradle ├── keyTest.jks ├── proguard-rules.pro ├── qq │ └── release │ │ ├── app-qq-release.apk │ │ └── output-metadata.json ├── src │ ├── baidu │ │ └── res │ │ │ ├── mipmap-xxhdpi │ │ │ └── logo.png │ │ │ └── values │ │ │ └── strings.xml │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── shi │ │ │ │ └── androidstudio │ │ │ │ └── multichannel │ │ │ │ └── MainActivity.java │ │ └── res │ │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ └── activity_main_activity__qq.xml │ │ │ ├── mipmap-xxhdpi │ │ │ ├── logo.png │ │ │ ├── logo_baidu.png │ │ │ └── logo_qq.png │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── qq │ │ └── res │ │ │ ├── mipmap-xxhdpi │ │ │ └── logo.png │ │ │ └── values │ │ │ └── strings.xml │ └── xiaomi │ │ └── res │ │ ├── mipmap-xxhdpi │ │ └── logo.png │ │ └── values │ │ └── strings.xml └── xiaomi │ └── release │ ├── app-xiaomi-release.apk │ └── output-metadata.json ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 多渠道打包之动态修改App名称,图标,applicationId,版本号,添加资源 2 | 3 | 近来公司有需求,同一套代码,要打包N套APP,而且这些APP的软件名称,软件图标,applicationId,版本号,甚至主页都不一样。之前都是单次修改,单次打包,可随着需求越来越多,需要打的包也会越来越多,单次打包费时费力,很明显已经不再适合,于是研究了一下,使用gradle成功实现了需要的功能,打包过程也变的更为简单。 4 | 5 | gradle是一个基于Apache Ant和Apache Maven概念的项目自动化建构工具。他可以帮助我们轻松实现多渠道打包的功能。 6 | 7 | - **效果图** 8 | 9 | ![多渠道打包.gif](http://upload-images.jianshu.io/upload_images/2761423-45b3ea86b630ad7e.gif?imageMogr2/auto-orient/strip) 10 | 11 | - **项目结构图** 12 | 13 | ![项目结构.png](http://upload-images.jianshu.io/upload_images/2761423-0ac8db9394a40b44.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 14 | 15 | - **项目结构中build.gradle的具体内容** 16 | 17 | ```groovy 18 | plugins { 19 | id 'com.android.application' 20 | } 21 | 22 | android { 23 | compileSdk 28 24 | 25 | defaultConfig { 26 | applicationId "com.shi.androidstudio.multichannel.baidu" 27 | minSdk 21 28 | targetSdk 28 29 | versionCode 1 30 | versionName "1.0" 31 | multiDexEnabled true//支持dex分包 32 | 33 | manifestPlaceholders = [CHANNEL_VALUE: "baidu"]//AndroidManifest.xml 里渠道变量 34 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 35 | flavorDimensions "default"//默认渠道 36 | resConfigs "en"//只保留默认的国际化标准 37 | 38 | ndk {//ndk的so库过滤 39 | abiFilters "armeabi"/*, "armeabi-v7a"*/, "arm64-v8a" 40 | } 41 | 42 | } 43 | 44 | // 使用签名文件进行签名的两种方式 45 | 46 | //第一种:使用gradle直接签名打包 47 | signingConfigs { 48 | config { 49 | storeFile file('keyTest.jks') 50 | storePassword '123456' 51 | keyAlias 'HomeKey' 52 | keyPassword '123456' 53 | } 54 | } 55 | //第二种:为了保护签名文件,把它放在local.properties中并在版本库中排除 56 | // ,不把这些信息写入到版本库中(注意,此种方式签名文件中不能有中文) 57 | // signingConfigs { 58 | // config { 59 | // storeFile file(properties.getProperty("keystroe_storeFile")) 60 | // storePassword properties.getProperty("keystroe_storePassword") 61 | // keyAlias properties.getProperty("keystroe_keyAlias") 62 | // keyPassword properties.getProperty("keystroe_keyPassword") 63 | // } 64 | // } 65 | 66 | //多渠道打包 67 | productFlavors { 68 | baidu {//QQ 69 | applicationId "com.shi.androidstudio.multichannel.baidu" 70 | // 动态修改 常量 字段 71 | buildConfigField "String", "ENVIRONMENT", '"我是百度首页"' 72 | // 修改 AndroidManifest.xml 里渠道变量 73 | manifestPlaceholders = [CHANNEL_VALUE: "baidu"] 74 | } 75 | qq {//百度 76 | applicationId "com.shi.androidstudio.multichannel.qq" 77 | // 动态修改 常量 字段 78 | buildConfigField "String", "ENVIRONMENT", '"我是腾讯首页"' 79 | // 修改 AndroidManifest.xml 里渠道变量 80 | manifestPlaceholders = [CHANNEL_VALUE: "qq"] 81 | } 82 | xiaomi {//小米 83 | applicationId "com.shi.androidstudio.multichannel.xiaomi" 84 | // 动态修改 常量 字段 85 | buildConfigField "String", "ENVIRONMENT", '"我是小米首页"' 86 | // 修改 AndroidManifest.xml 里渠道变量 87 | manifestPlaceholders = [CHANNEL_VALUE: "xiaomi"] 88 | } 89 | } 90 | 91 | buildTypes { 92 | debug { 93 | // debug模式下,显示log 94 | buildConfigField("boolean", "LOG_DEBUG", "true") 95 | //为已经存在的applicationId添加后缀 96 | applicationIdSuffix ".debug" 97 | // 为版本名添加后缀 98 | versionNameSuffix "-debug" 99 | // 不开启混淆 100 | minifyEnabled false 101 | // 不移除无用的resource文件 102 | // shrinkResources false 103 | // 使用config签名 104 | signingConfig signingConfigs.config 105 | 106 | } 107 | release { 108 | // release模式下,不显示log 109 | buildConfigField("boolean", "LOG_DEBUG", "false") 110 | // 为版本名添加后缀 111 | versionNameSuffix "-relase" 112 | // 不开启混淆 113 | minifyEnabled false 114 | // 移除无用的resource文件 115 | // shrinkResources true 116 | // 使用config签名 117 | signingConfig signingConfigs.config 118 | // 混淆文件位置 119 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 120 | } 121 | 122 | } 123 | //移除lint检测的error 124 | lintOptions { 125 | checkReleaseBuilds false 126 | abortOnError false 127 | } 128 | 129 | aaptOptions { 130 | //防止java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed 131 | noCompress 'mp3', 'aac', 'mp4', 'wav' 132 | cruncherEnabled false //用来关闭Android Studio的PNG合法性检查的,直接不让它检查。 133 | useNewCruncher(false) 134 | } 135 | 136 | 137 | compileOptions {//知名使用的JDK版本 138 | sourceCompatibility JavaVersion.VERSION_1_8 139 | targetCompatibility JavaVersion.VERSION_1_8 140 | } 141 | 142 | // 批量打包 143 | applicationVariants.all { variant -> 144 | variant.outputs.each { output -> 145 | if (output.name == 'release') { 146 | variant.packageApplicationProvider.get().outputDirectory = new File(project.rootDir.absolutePath + "/app") 147 | //输出apk名称为:版本名_版本code_时间.apk 148 | def fileName = "MiChat_v${defaultConfig.versionName}_code${defaultConfig.versionCode}_t${releaseTime()}_release.apk" 149 | output.outputFileName = fileName 150 | } 151 | } 152 | } 153 | 154 | 155 | } 156 | 157 | dependencies { 158 | implementation 'androidx.appcompat:appcompat:1.3.0' 159 | implementation 'com.google.android.material:material:1.4.0' 160 | } 161 | ``` 162 | 163 | - **项目结构中local.properties的具体内容** 164 | 165 | ```java 166 | ## This file must*NOT*be checked into Version Control Systems, 167 | # as it contains information specific to your local configuration. 168 | # 169 | # Location of the SDK.This is only used by Gradle. 170 | # For customization when using a Version Control System,please read the 171 | # header note. 172 | #Tue Mar 29 17:45:25CST 2022 173 | sdk.dir=D\:\\Android_SDK 174 | #对应自己实际的证书路径和名字,在这里由于签名文件是放在app目录下,因为没有写绝对路径。 175 | keystroe_storeFile=keyTest.jks 176 | keystroe_storePassword=123456 177 | keystroe_keyAlias=HomeKey 178 | keystroe_keyPassword=123456 179 | ``` 180 | 181 | 看完build.gradle和local.properties的具体内容之后,我们再来挑选几个地方来具体说一下。 182 | 183 | ### 一. signingConfigs 184 | 185 | 在signingConfigs中主要是为打包配置签名文件具体信息的,这里我使用了两种方式,第一种方式把签名文件的位置,storePassword ,keyAlias,keyPassword 186 | 等具体内容都直接写在其中,然后使用gradle进行打包,第二种是通过通过使用local.properties文件来间接加载签名文件的具体信息。一般我们更倾向于第二种方法,这样有助于保护我们的签名文件(在local.properties中不能有中文)。 187 | 188 | ### 二. productFlavors 189 | 190 | 不同渠道的设置基本都是在 productFlavors 里设置的,在里面想要添加多少个渠道都可以。 191 | 192 | ### 修改app名称、图标 193 | 194 | 当我们在productFlavors 中添加了不同渠道环境名称之后,我们还可以mian文件夹同层级中建立和baidu,qq,xiaomi名称对应的文件夹, 195 | 并放入特定的string.xml文件,图标文件,当然我们还可以放入其他color.xml、dimen.xml等资源文件,甚至AndroidManifest.xml都可以放入, 196 | Gradle在构建应用时,会优先使用flavor所属dataSet中的同名资源,这样就能达到不同环境不同软件图标的功能。 197 | 198 | ![修改软件图标.png](http://upload-images.jianshu.io/upload_images/2761423-3aa0b6c4326db3a7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 199 | 200 | 简单介绍就到这里了,做个笔记方便以后使用,如果"不小心"帮到别人了当然也是极好的了。 201 | [最后附上github上的项目地址](https://github.com/AFinalStone/MultiChannel-master)以及[整个demo下载地址](http://download.csdn.net/detail/abc6368765/9650523) 202 | 203 | ### 最后再推荐一个批量打马甲包的脚本项目,使用该脚本可以起到批量修改app名字和logo的作用 204 | 205 | ### [点我进入传送门](https://github.com/AFinalStone/jiagu) -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/baidu/release/app-baidu-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/baidu/release/app-baidu-release.apk -------------------------------------------------------------------------------- /app/baidu/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.shi.androidstudio.multichannel.baidu", 8 | "variantName": "baiduRelease", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "attributes": [], 14 | "versionCode": 1, 15 | "versionName": "1.0-relase", 16 | "outputFile": "app-baidu-release.apk" 17 | } 18 | ], 19 | "elementType": "File" 20 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 28 7 | 8 | defaultConfig { 9 | applicationId "com.shi.androidstudio.multichannel.baidu" 10 | minSdk 21 11 | targetSdk 28 12 | versionCode 1 13 | versionName "1.0" 14 | manifestPlaceholders = [CHANNEL_VALUE: "baidu"]//AndroidManifest.xml 里渠道变量 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | flavorDimensions "default"//默认渠道 17 | resConfigs "en"//只保留默认的国际化标准 18 | 19 | ndk {//ndk的so库过滤 20 | abiFilters "armeabi"/*, "armeabi-v7a"*/, "arm64-v8a" 21 | } 22 | 23 | } 24 | 25 | // 使用签名文件进行签名的两种方式 26 | 27 | //第一种:使用gradle直接签名打包 28 | signingConfigs { 29 | config { 30 | storeFile file('keyTest.jks') 31 | storePassword '123456' 32 | keyAlias 'HomeKey' 33 | keyPassword '123456' 34 | } 35 | } 36 | //第二种:为了保护签名文件,把它放在local.properties中并在版本库中排除 37 | // ,不把这些信息写入到版本库中(注意,此种方式签名文件中不能有中文) 38 | // signingConfigs { 39 | // config { 40 | // storeFile file(properties.getProperty("keystroe_storeFile")) 41 | // storePassword properties.getProperty("keystroe_storePassword") 42 | // keyAlias properties.getProperty("keystroe_keyAlias") 43 | // keyPassword properties.getProperty("keystroe_keyPassword") 44 | // } 45 | // } 46 | 47 | //多渠道打包 48 | productFlavors { 49 | baidu {//QQ 50 | applicationId "com.shi.androidstudio.multichannel.baidu" 51 | // 动态修改 常量 字段 52 | buildConfigField "String", "ENVIRONMENT", '"我是百度首页"' 53 | // 修改 AndroidManifest.xml 里渠道变量 54 | manifestPlaceholders = [CHANNEL_VALUE: "baidu"] 55 | } 56 | qq {//百度 57 | applicationId "com.shi.androidstudio.multichannel.qq" 58 | // 动态修改 常量 字段 59 | buildConfigField "String", "ENVIRONMENT", '"我是腾讯首页"' 60 | // 修改 AndroidManifest.xml 里渠道变量 61 | manifestPlaceholders = [CHANNEL_VALUE: "qq"] 62 | } 63 | xiaomi {//小米 64 | applicationId "com.shi.androidstudio.multichannel.xiaomi" 65 | // 动态修改 常量 字段 66 | buildConfigField "String", "ENVIRONMENT", '"我是小米首页"' 67 | // 修改 AndroidManifest.xml 里渠道变量 68 | manifestPlaceholders = [CHANNEL_VALUE: "xiaomi"] 69 | } 70 | } 71 | 72 | buildTypes { 73 | debug { 74 | // debug模式下,显示log 75 | buildConfigField("boolean", "LOG_DEBUG", "true") 76 | //为已经存在的applicationId添加后缀 77 | applicationIdSuffix ".debug" 78 | // 为版本名添加后缀 79 | versionNameSuffix "-debug" 80 | // 不开启混淆 81 | minifyEnabled false 82 | // 不移除无用的resource文件 83 | // shrinkResources false 84 | // 使用config签名 85 | signingConfig signingConfigs.config 86 | 87 | } 88 | release { 89 | // release模式下,不显示log 90 | buildConfigField("boolean", "LOG_DEBUG", "false") 91 | // 为版本名添加后缀 92 | versionNameSuffix "-relase" 93 | // 不开启混淆 94 | minifyEnabled false 95 | // 移除无用的resource文件 96 | // shrinkResources true 97 | // 使用config签名 98 | signingConfig signingConfigs.config 99 | // 混淆文件位置 100 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 101 | } 102 | 103 | } 104 | //移除lint检测的error 105 | lintOptions { 106 | checkReleaseBuilds false 107 | abortOnError false 108 | } 109 | 110 | aaptOptions { 111 | //防止java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed 112 | noCompress 'mp3', 'aac', 'mp4', 'wav' 113 | cruncherEnabled false //用来关闭Android Studio的PNG合法性检查的,直接不让它检查。 114 | useNewCruncher(false) 115 | } 116 | 117 | 118 | compileOptions {//知名使用的JDK版本 119 | sourceCompatibility JavaVersion.VERSION_1_8 120 | targetCompatibility JavaVersion.VERSION_1_8 121 | } 122 | 123 | // 批量打包 124 | applicationVariants.all { variant -> 125 | variant.outputs.each { output -> 126 | if (output.name == 'release') { 127 | variant.packageApplicationProvider.get().outputDirectory = new File(project.rootDir.absolutePath + "/app") 128 | //输出apk名称为:版本名_版本code_时间.apk 129 | def fileName = "MiChat_v${defaultConfig.versionName}_code${defaultConfig.versionCode}_t${releaseTime()}_release.apk" 130 | output.outputFileName = fileName 131 | } 132 | } 133 | } 134 | 135 | 136 | } 137 | 138 | dependencies { 139 | implementation 'androidx.appcompat:appcompat:1.3.0' 140 | implementation 'com.google.android.material:material:1.4.0' 141 | } -------------------------------------------------------------------------------- /app/keyTest.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/keyTest.jks -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android_Studio\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/qq/release/app-qq-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/qq/release/app-qq-release.apk -------------------------------------------------------------------------------- /app/qq/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.shi.androidstudio.multichannel.qq", 8 | "variantName": "qqRelease", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "attributes": [], 14 | "versionCode": 1, 15 | "versionName": "1.0-relase", 16 | "outputFile": "app-qq-release.apk" 17 | } 18 | ], 19 | "elementType": "File" 20 | } -------------------------------------------------------------------------------- /app/src/baidu/res/mipmap-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/src/baidu/res/mipmap-xxhdpi/logo.png -------------------------------------------------------------------------------- /app/src/baidu/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 百度 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/shi/androidstudio/multichannel/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.shi.androidstudio.multichannel; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.widget.TextView; 6 | 7 | import androidx.appcompat.app.AppCompatActivity; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | public static final String ENVIRONMENT = BuildConfig.ENVIRONMENT; 12 | 13 | private TextView tv_content; 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(savedInstanceState); 18 | setContentView(R.layout.activity_main); 19 | tv_content = (TextView) findViewById(R.id.tv_content); 20 | tv_content.setText(ENVIRONMENT); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main_activity__qq.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/src/main/res/mipmap-xxhdpi/logo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/logo_baidu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/src/main/res/mipmap-xxhdpi/logo_baidu.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/logo_qq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/src/main/res/mipmap-xxhdpi/logo_qq.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 默认应用名称 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /app/src/qq/res/mipmap-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/src/qq/res/mipmap-xxhdpi/logo.png -------------------------------------------------------------------------------- /app/src/qq/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 腾讯 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/xiaomi/res/mipmap-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/src/xiaomi/res/mipmap-xxhdpi/logo.png -------------------------------------------------------------------------------- /app/src/xiaomi/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 小米 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/xiaomi/release/app-xiaomi-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/app/xiaomi/release/app-xiaomi-release.apk -------------------------------------------------------------------------------- /app/xiaomi/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "com.shi.androidstudio.multichannel.xiaomi", 8 | "variantName": "xiaomiRelease", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "attributes": [], 14 | "versionCode": 1, 15 | "versionName": "1.0-relase", 16 | "outputFile": "app-xiaomi-release.apk" 17 | } 18 | ], 19 | "elementType": "File" 20 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id 'com.android.application' version '7.1.2' apply false 4 | id 'com.android.library' version '7.1.2' apply false 5 | } 6 | 7 | task clean(type: Delete) { 8 | delete rootProject.buildDir 9 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/MultiChannel-master/64ac79212802f26950de6f768984ce11d0b92fb8/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Mar 28 11:29:03 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "MultiChannel" 16 | include ':app' 17 | --------------------------------------------------------------------------------