Separation of the app production and development environment (teaches you)

Source: Internet
Author: User

In the development, when the product is iterative upgrade, sometimes encounter this situation, the phone has installed a product already on-line, but also in the development of a product that is being developed, then can only uninstall one, to install another, more trouble, and the development version and release of some configuration is not the same, such as the interface address, third-party app key, etc., these content if directly in the code to change to be more troublesome, but also prone to error.

So here, we will share with you how the production and development of the environmental separation.

1. First, in project structure, there are two versions of debug and release in Build Tyoes, and we only need to enter it in the debug version of Application Id Suffix. Debug (whatever you call it, Note the following steps are consistent), release version does not move

2, in the SRC directory to create a new debug directory, directory name and application Id suffix consistent, and then in the Debug directory to create a new res directory, in the Res directory under the image and Values folder,

The catalogue here is not mistaken, when we choose the Debug version at runtime, the contents of the picture and strings will automatically replace the corresponding resource file in the main directory.

Strings put some debug and release versions of different configuration information:

This shows the app name, interface root address, and local cache file path.

We take different values from the OnCreate in application, depending on whether the runtime chooses debug or release.




3, the runtime in the buildvariants kind of choice is to run Debug and is release version


It is important to note that when you run the release version, if you do not configure the signature file information, you will be reported:

Error
APP-RELEASE-UNSIGNED.APK is not signed. Please configure the signing information for the selected flavor using the Project Structure dialog.
Open Project Structure Dialog

1), at this point, we first want to add the signature file information in the signing of project structure,


2), and then in flavors, select Signing Config as the signature file information that you just configured



To this step is basically completed the production and development of the environmental separation, you can install in the mobile phone production and development of two versions of the application, do not have to uninstall the installation every time.


Note that: In android5.0 above the system, the authority of the management has been strengthened, so debug and release signature files to be consistent to install the success, otherwise it will be reported install_failed_duplicate_permission Permission error.

So we select the same signature file for the debug and Release signing config option in Buildtypes, and the installation of Relase and debug will not be an error.


Reference Documentation:

Http://www.tuicool.com/articles/yAZBjeA


Separation of the app production and development environment (teaches you)

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.