Answer the question
In order to leave comments, you need to log in
How to create different Android application configurations?
There is an Android application that has a Configuration.java class containing configurations for the dev and production versions of the application. Depending on which version is required, the settings change and the application is built. There was a desire to automate this business and Gradle was chosen as a tool.
The idea is the following: create 2 copies of the Configuration.java file and, depending on the required version of the application, build it with one version of the file or with another. I saw a solution on Ant, but I could not do it on Gradle. The buildTypes section looks like this:
buildTypes {
dev {
packageNameSuffix ".dev"
}
prod {
packageNameSuffix ".prod"
}
}
Answer the question
In order to leave comments, you need to log in
I am answering my own question.
A small manual:
1. Organize the directory structure as follows
src
main
java
com.example.application
MainActivity.java
res
AndroidManifest.xml
dev
java
com.example.application.config
Configuration.java
pro
java
com.example.application.config
Configuration.java
productFlavors {
dev {
...
}
pro {
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question