I have not found an easy way to get Eclipse to generate the BuildConfig class.
I mainly develop with Eclipse ADT and then release various options with Gradle, so I came up with the following solution:
Create your own CustomBuildConfig class, add it to the Eclipse build path, and use Gradle sourceSets to select a different version of this class.
In Project/build.gradle define an additional flavor-specific source folder:
android { sourceSets { release_prod { java.srcDirs = ['src', 'flavors/prod/src' ] } release_dev { java.srcDirs = ['src', 'flavors/dev/src' ] } }
The production env is defined in Project/flavors/prod/src/CustomBuildConfig.java:
package com.example.project; public class CustomBuildConfig { public static final String ENVIRONMENT = "prod"; }
Env development is defined in Project/flavors/dev/src/CustomBuildConfig.java:
package com.example.project; public class CustomBuildConfig { public static final String ENVIRONMENT = "dev"; }
And finally, in Eclipse, I only add the Project/flavors/dev/src/ path to the build path.
source share