Gradle Packaging App Signature
By default, debug is configured to use one of the debug keystory. The debug keystory uses the default password and default key and the default key password. The Debug build type is automatically configured with the debug signature. In your module's Build.gradle file, add:
Android { ... " Yanbober.keystore ") Storepassword " Gradle "Keyalias " Gradle "Keypassword " Gradle "}} buildtypes{Release {Runproguard true zipalignenabled true // Remove useless resource files shrinkresources true proguardfiles getdefaultproguardfile ( Proguard-android.txt '), ' Proguard-rules.pro ' Signingconfig signingConfigs .myconfig}} }
Although the relative path of the project root is often used as the path to the KeyStore, an absolute path can also be used, although this is not recommended (except for the automatically created debug KeyStore). Run the Gradle clean Gradle build to generate a signature confusion-aligned app.
Gradle build Android apps Multi-Channel pack (bulk package)
The release of Android apps needs to face a variety of markets, which we call channels. Usually as a developer we need to know which channel the app was downloaded from. This statistical information is commonly used in Baidu statistics or friends League statistics.
Here, for example, use the Friends League statistics as an example to illustrate the problem. The principle is Gradle manifest merger.
Configure the so-called placeholder in Androidmanifest.xml.
<meta-data android:name="CHANNEL" android:value="${CHANNEL_VALUE}" />
In the defaultconfig of the module Build.gradle file plus placeholder, the function is to declare channel_value to be the placeholder of the replaceable value and set the Yanbober default value for it.
android { ...... defaultConfig { ...... manifestPlaceholders = [ CHANNEL_VALUE:"yanbober" ] } }
Add the Productflavors configuration to the module's Build.gradle file.
Productflavors is actually a definable product attribute, and with manifest merger it is possible to produce multiple versions with their own feature configurations during a single compilation.
The purpose of this configuration is to produce different channel_value values for each channel package.
android { ...... defaultConfig { ...... manifestPlaceholders = [ CHANNEL_VALUE:"yanbober" ] } productFlavors { yanbober{} wandoujia{} xiaomi{} baidu{} } productFlavors.all { flavor -> flavor.manifestPlaceholders = [ CHANNEL_VALUE:name ] } }
Batch build multi-Channel package: Enter the project directory to run Gradlew assemblerelease. You can see that the compilation produced a total of 4 apk, respectively, corresponding to the 4 channels defined in the Productflavors segment. Anti-compilation opens androidmanifest.xml you will find that the channel configuration has been modified.
Generate a single channel package: Open as the Gradle Tasks panel module has many tasks, directly double-click the corresponding delay channel task to generate the corresponding apk.
It would be nice to use Gradlew assemblexiaomirelease to generate Xiaomi channels separately using the command line.
Android Studio Learning----Packaging