urSus
urSus

Reputation: 12739

How to use applicationId outside defaultConfig in gradle?

This is possibly a silly quiestion, but I want to have a debug and release versions of app working at the same time on device.

The problem I had is a content resolver authority. So I did the usual applicationId jazz, but now i want to avoid having code like this

public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".provider";

laying around, so I figured I would do a BuildConfigField for CONTENT_AUTHORITY which would do the concat in buildfile already like this

buildTypes {
    debug {
        applicationIdSuffix ".debug"
        BuildConfigField "String", "CONTENT_AUTHORITY", "\"${applicationId}.provider\"")
    }
    release {
        ....
    }
}

But it doesnt work, gradle/groovy syntax is confusing for me, help please?

Error:(32, 0) Could not find property 'applicationId' on BuildType_Decorated{name=debug, debuggable=true, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, applicationIdSuffix=.debug, versionNameSuffix=null, minifyEnabled=false, zipAlignEnabled=true,...

Upvotes: 3

Views: 1442

Answers (1)

Viral Patel
Viral Patel

Reputation: 33408

Try accessing it as

defaultConfig.applicationId

Instead of just

applicationId

Should get you the value.

Upvotes: 3

Related Questions