How To Encrypt Passwords In Build.gradle With Android 3.3? Getting "Cannot Resolve Symbol" In IDE

Since update to Android Studio 3.3 we get a weird warning with some legacy code about encrypted gradle parameters.

In build.gradle we have this line:

apply from: "encryption.gradle"

In encryption.gradle we have this content:

afterEvaluate {
    android.applicationVariants.all { variant ->
        def pwd = "";
        variant.productFlavors.each { flavor ->
            if (flavor.ext.has("pwd1")) {
                pwd = flavor.ext.pwd1
        if (pwd.isEmpty() && variant.buildType.ext.has("pwd2")) {
            pwd = variant.buildType.ext.pwd2
        variant.resValue 'string', 'pwd', encryptPassword(pwd, variant.signingConfig, variant.applicationId)

def String encryptPassword(String password, signingConfig, String applicationId) {

In the code we use it like this:


And since the AS update we get the following error:

Cannot resolve symbol 'pwd'

When compiling/building the project everything runs fine because it can find the parameter. But when working in the IDE, all files that try to use R.string.pwd are marked red and show the error message, which is pretty annoying.

Any way to make this go away easily? SuppressWarnings("all") and SuppressLint("all") are not helping.

Is afterEvaluate the right place to do this or would it be better somehow in the defaultConfig section of build.gradle?



Even i was facing similar issues. so i reverted my gradle to 3.2.1 and it works as expected, it might be a technical glitch/issue with gradle 3.3

While i was on gradle 3.3 i tried invalidating cache for android studio, restarted it etc, but nothing solved the issue.