For multi-channel signature packaging, you can refer directly to the Gradle script provided by the league.
Umeng-muti-channel-build-tool
Because multiple three-party plug-ins are referenced in the project (e.g. map service, push service, Statistics service, etc.)
The corresponding package name is different (for the convenience of testing to differentiate between the test & the official version), so the corresponding service Appkey is not the same
So I made a change to this script.
Build.gradle
apply plugin: ' Com.android.application ' dependencies { compile Filetree (dir: ' Libs ', include: [' *.jar ']) compile filetree (dir: ' Libs ', include: ' **/*.so ') compile ' Com.android.support: appcompat-v7:20.0.0 '}android { compilesdkversion integer.parseint (project. android_build_sdk_version) buildtoolsversion project. android_build_tools_version defaultconfig { applicationid project. android_build_applicationid_debug minsdkversion Integer.parseint (android_build_min_sdk_version) Targetsdkversion integer.parseint (android_build_target_sdk_version) versioncode integer.parseint (ProjeCt. Version_code) versionname project. version_name } //Channel productflavors { develop { } production { Applicationid project. android_build_applicationid_production } googleplay { applicationid project. android_build_applicationid_production } wandoujia { applicationid project. android_build_applicationid_production }// store91 {// applicationid project. android_build_applicationid_production// }// qq {// applicationid project. android_build_applicationid_production// }// anzhi {// applicationid project. android_build_applicationid_production// } } sourcesets { main { assets.srcdirs = [' Assets '] jnilibs.srcdirs = [ ' Libs '] } } //signature signingConfigs{ release { storefile file ("KeyStore path") storePassword "* * *" keyAlias "* * *" keyPassword "* * *"         } } buildTypes { release { runProguard false proguardfiles getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro ' signingConfig signingConfigs.release } } packagingOptions { exclude ' meta-inf/dependencies ' exclude ' Meta-inf/notice ' exclude ' meta-inf/license ' exclude ' Meta-inf/license.txt ' exclude ' Meta-inf/notice.txt ' } // This is the code to solve lint error lintOptions { abortonerror false // prevents missingtranslation caused by build failed! at the time of release disable ' missingtranslation ' }}tasks.withtype (Compile) { options.encoding = "UTF-8"}//replace Androidmanifest.xml umeng_channel_value string for channel name by Remex Huangandroid.applicationVariants.all{ variant -> variant.processmanifest.dolast{ //used here before the copy{}, I replaced the file operation, This allows the v1.11 version to run properly and keep the folder neat //${builddir} refers to./build folder //${variant.dirname} is flavor/buildtype, such as Googleplay/release, which is automatically generated by the runtime //The following path is similar to this:./build/manifests/googleplay/release/ androidmanifest.xml def manifestfile = "${ Builddir}/intermediates/manifests/${variant.dirname}/androiDmanifest.xml " //replace string umeng_channel_value with flavor name def updatedcontent = new file (ManifestFile). GetText (' UTF-8 '). ReplaceAll ("Umeng_channel_value", "${variant.productflavors[0].name}") //Replace the package name, appkey if ("develop"). Equalsignorecase ("${variant.productflavors[0].name}")) { updatedcontent = updatedcontent.replaceall ("Baidu_appkey_value", "${project. Baidu_appkey_value_debug} "). ReplaceAll (" Umeng_appkey_value ", " ${project. Umeng_appkey_value_debug} "). ReplaceAll (" Jpush_appkey_value ", " ${project. Jpush_appkey_value_debug} "). ReplaceAll (" ApplicationID ", " ${project. Android_build_applicationid_debug} ") } else { updatedcontent = updatedcontent.replaceall ("BAIDU_ Appkey_value ", " ${project. Baidu_appkey_value_product} "). ReplaceAll (" Umeng_appkey_value ", " ${project. Umeng_appkey_value_product} "). ReplaceAll (" Jpush_appkey_value ", " ${project. Jpush_appkey_value_product} "). ReplaceAll (" ApplicationID ", " ${project. Android_build_applicationid_production} ") } new file (Manifestfile). Write (updatedcontent, ' UTF-8 ') //the flavor androidmanifest.xml file as the file we have modified variant.processresources.manifestfile = file ("${buildDir}/intermediates/ Manifests/${variant.dirname}/androidmanifest.xml ") }}
Gradle.properties
android_build_tools_version=19.1.0android_build_sdk_version=19version_name=1.0version_code=1group= Com.fallenpanda.appandroid_build_min_sdk_version=7android_build_target_sdk_version=15#debug Package Name Android_build_ Applicationid_debug=com.fallenpanda.app.demo#production Package Name android_build_applicationid_production= com.fallenpanda.appbaidu_appkey_value_debug= Baidu Map Service DEBUG package name corresponding to appkeybaidu_appkey_value_product= Baidu map service Production package name corresponding to the Appkeyumeng_appkey_value_debug= Friend Union service DEBUG package name corresponding to the Appkeyumeng_appkey_value_product= Friend Alliance service Production package name corresponding to the appkeyjpush_appkey_value_debug= Aurora push Service DEBUG package name corresponding to the appkeyjpush_appkey_value_product= Aurora push Service Production package name corresponding to the Appkey
Androidmanifest.xml
Where you need to replace the package name with ApplicationID instead
Channel with Umeng_channel_value Replacement
APPKEY are replaced by Baidu_appkey_value, Umeng_appkey_value, Jpush_appkey_value, respectively.
------------------------------------
Last Clean
Execute assemblegoogleplayrelease Separately, generate channel packages separately
or execute assemblerelease directly, build together
You can find the generated apk in the project build\outputs\apk directory
The-unaligned suffix apk is just a middle product, directly ignoring
-release suffix is the official signature of each channel APK.
Reference Original address:http://my.oschina.net/uboluo/blog/157483
Android Studio Gradle Multichannel, multi-appkey signature packaging