background

Scene:

The project has two apps, each with its own Gradle. properties. Both apps rely on the same Android Library: CommonLib

Original plan:

The two apps are placed in two Android projects. CommonLib is placed in one of the Android projects. The other Project relies on CommonLib remotely. Pain points:

  1. When you modify CommonLib, the remotely dependent Project code cannot be automatically modified.
  2. Package upload and download synchronization time.

The solution

Putting two App Modules in the same Project

  1. Properties in Project Gradle. properties are to be transferred to the corresponding App Module Properties

Loads data from the specified properties file

  1. Create a properties file under the corresponding module, for example, app.properties.
  2. Load the file in build.gradle
def appProperties = new Properties()
appProperties.load(new FileInputStream(getProject().file("app.properties")))
Copy the code
  1. Use the propertie object to get the value
appProperties['BASE_URL']
Copy the code