Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default buildConfigField for non-specific combinations #10

Closed
lucanicoletti opened this issue Jun 29, 2023 · 2 comments
Closed

default buildConfigField for non-specific combinations #10

lucanicoletti opened this issue Jun 29, 2023 · 2 comments

Comments

@lucanicoletti
Copy link

In our app we currently have 6 productFlavors

productFlavors {
    create("local") {} // the first three are dimension `environment`
    create("staging") {}
    create("production") {}
    create("type1") {} // this and the following are dimension `app`
    create("type2") {}
    create("type3") {}
    create("type4") {}
 }

Then inside the porflavor block, we specify for only a few combinations some BuildConfigFields:

porflavor {
   create("localType1") { 
       buildConfigField("String", "CLIENT_ID", """"id"""")
    }
   create("stagingType1") { 
       buildConfigField("String", "CLIENT_ID", """"id"""")
    }
   create("stagingType2") { 
       buildConfigField("String", "CLIENT_ID", """"id"""")
    }
   create("stagingType3") { 
       buildConfigField("String", "CLIENT_ID", """"id"""")
    }
   create("productionType2") { 
       buildConfigField("String", "CLIENT_ID", """"id"""")
    }
}

But for some of the combinations possible, some of the buildConfigField are missing, and when selecting one of the lacking BuildVariants from Android Studio, or when running the generic ./gradlew build (which I'm trying to setup on CI, the builds fail as there is no BuildConfig.CLIENT_ID specified.

Should I specify all the BuildConfigField for every possible combination?

@lucanicoletti
Copy link
Author

Defining buildConfigFielf() in the defaultConfig block solves the builds problem! :)

@nikialeksey
Copy link
Owner

Yeah, you are right! defaultConfig exists exactly for that. And you can override default config in flavors. If you don't want to define default config, than you have to define this field for all flavors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants