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:
- When you modify CommonLib, the remotely dependent Project code cannot be automatically modified.
- Package upload and download synchronization time.
The solution
Putting two App Modules in the same Project
- Properties in Project Gradle. properties are to be transferred to the corresponding App Module Properties
Loads data from the specified properties file
- Create a properties file under the corresponding module, for example, app.properties.
- Load the file in build.gradle
def appProperties = new Properties()
appProperties.load(new FileInputStream(getProject().file("app.properties")))
Copy the code
- Use the propertie object to get the value
appProperties['BASE_URL']
Copy the code