You can use the BuildConfig class, for example:
android { buildTypes { debug { buildConfigField 'String', 'API_URL', 'http://...' } release { buildConfigField 'String', 'API_URL', 'http://...' } } }
Or, if you do not want to save the URL in build.gradle , you can use the debug and release folders to create a special class that stores the URL:
debug\src\java\com\myapp\ApiParam.javarelease\src\java\com\myapp\ApiParam.java
Now, in your main project, you can reference the ApiParam class.
source share