Use Gradle packaging in Android Studio

Source: Internet
Author: User

The first thing to note, Android Studio in the Proguard.txt has been named Proguard-rules.pro, this shows that the use of gradle packaging, confusion rules file name is not important, you can name it yourself. The confusion rule is the same as the original, without change. I don't know how to write a search for someone else.

Add signature files to the build->generate signed APK ...


You'll see the following pop-up box


If you do not have a signed file to create a new signature file, if you already have a signature file, then select the location of the signature file, and fill in the password can click Next. The signature file is created in the same way as the old version (Eclipse+adt), which is no longer spoken. You will find that the signature file generated by as is jks suffix, unlike the original can say tore, in fact, the signature file is not affected by the file name.

Next, the following box pops up


In the BUiD type default has two options, so the name Incredibles, we usually use debug, formally packaged, we need to use release, select after the point of finish can be packaged. But this package does not confuse the code, and we continue to add code obfuscation.

Select the project's Open Module Setting, and we'll see the box below


We selected App->signing Click + Sign, new general configuration, this configuration is just need to manually input and import signature files, we can in this config (can be named) the signature password and signature file path.

Then we'll point to the Build Types tab.


This is our formal contract to configure the content, the other selected by default. Need to change two places: Signing Config, select the signature configuration we just set, in the Proguard file column, select the absolute path of Proguard-rules.pro in the project, which is the app/under the project root directory. Proguard-rules.pro, then click OK. Gradle will automatically sync the modified content.

This time we look at the contents of the Build.gradle in the app directory, and you will find that the content we have just configured is identical.

Below I can pack the official signed APK package. There are three ways of doing this:

1. In build-> Generate signed APK ... The next step is to package it directly;

2. Enter Gradlew release in the as provided terminal, or open the external terminal to the project's directory and enter Gradlew release. However, this premise is that the Gradle is already installed on the machine, and the environment variable is configured, otherwise the terminal cannot recognize such a command.

3. Using the AS default Gradle plug-in, the right side of our window can be found Gradle (by default is minimized), open it and click on the project name and next layer, see there is a tasks->build, find assemblerelease (bulk packaging) and double-click, is automatically packaged.

Formal signature Package If the directory is not changed by default in the app directory or in the app/build/output/apk directory, the individual prefers to put it in the back directory.

Also note that to modify the package version information, you need to modify the following red content in the Build.gradle, like Manifest.xml

Defaultconfig {

ApplicationID ' Com.arjinmc.goddnessplan '

Minsdkversion 14

Targetsdkversion 22

Versioncode 2

Versionname ' 0.0.2 '

Signingconfig Signingconfigs.config

}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use Gradle packaging in Android Studio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.