Pregunta

I created new app in Android Studio and I put into my gradle file two flavours. Sadly IDE generates for me some wierd build types with prefix adsenseTag and I don't know how to remove it.

buildTypes {
    release {
        runProguard true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }

    debug.initWith(buildTypes.release)
    debug {
        debuggable true
        runProguard false
        signingConfig signingConfigs.debug
    }
}

productFlavors {
    free {
        packageName freePackage

        buildConfigField "java.lang.String", "AD_SENSE_TAG", "\"$adsenseTagFree\""
    }

    paid {
        packageName paidPackage

        buildConfigField "java.lang.String", "AD_SENSE_TAG", "\"$adsenseTagPaid\""
    }
} 

And here is screen from my Build Variants window:

enter image description here

¿Fue útil?

Solución

What are you trying to accomplish with the GString notation (the $ in strings like "\"$adsenseTagFree\"")? That's what's confusing it -- in my test project, if I remove the $, it acts normally. It would take some research to figure out exactly what's going on, but I know it's happening at the Gradle level, not the Android Studio level, because running gradlew tasks from the command line reveals the same bogus task names. I suspect it has something to do with exactly when that GString gets expanded in the buildfile evaluation/execution process.

If you don't need the $ notation, then just remove it; if you do, then provide more details on what you're trying to accomplish with it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top