Android resource file local.properties use and value in Gradle file, value in Manifests file

This article is also summed up because of the problem of Gradle storage keys. At the beginning of the period, there were doubts about the creation of .properties because I was viewing the newly created properties under Android and could not see it.

Because Gradle Scripts is built by the system, it cannot be seen in this directory and can only be seen in the root directory

Then the resource file personally thinks to put some custom configuration information, or it can put some third-party AppIDs

At this time, the problem of using .properties is to get and write the value in Gradle, and then add the meta-data tag in the Manifests Application

1- Load the properties file in the build.gradle file in the APP directory

Properties properties = new Properties()
properties.load(project.rootProject.file('version.properties').newDataInputStream())

 

2-Add the manifestPlaceholds tag setting value to the defaultConfig tag under the android tag of the build.gradle file in the APP directory 

 

3-Add the meta-data tag ${wxApid} in the AndroidManifest.xml file, "wxApid" is the key name in manifestPlaceholds, and it is obtained through the name set by android:name

  

4- The last step is to get the value by obtaining the value in the manifests file, which may be quite confusing, but at present I only see this step ~ ~ ~ ~, in the tool class to obtain the value through the code, the value type obtained needs to be consistent

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325007627&siteId=291194637