Could not find property 'generateResources' on com.android.build.gradle.internal.api

Hey guys. I’m using gradle in my Android project and I’m trying to bundle an android string resource file that’s generated by a script at build time. However I only want to do this during a debug build, so I’ve written something like this.

applicationVariants.all {
    variant ->
        variant.outputs.each { output ->
            if (variant.buildType.debuggable) {
                output.generateResources.dependsOn("retrievePasswords")
            } else {
                output.generateResources.dependsOn("retrieveDefaultPasswords")
            }
        }
}

The problem I’m having is that I get “Could not find property ‘generateResources’ on com.android.build.gradle.internal.api”. I’ve tried processResources, but that’s too late in the process and the file isn’t placed in the resources folder before they’re all compiled into the R file.

Any ideas on another task I could use or how to get generateResources working?

1 Like