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

ligi picture ligi · Nov 24, 2014 · Viewed 22.2k times · Source

After updating to AS 1.0 RC 1 and plugin 0.14.4 I am having problems with the renaming part of my build.gradle:

applicationVariants.all { variant ->
            def file = variant.outputFile
            variant.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
        }

throws now:

Error:(78, 0) Could not find property 'outputFile' on com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@67e7625f.

and also I cannot jump to the class ApplicationVariantImpl to look how the property might have been renamed. Anyone knows workarounds for this?

Answer

Oleg Khalidov picture Oleg Khalidov · Nov 25, 2014

try this

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def file = output.outputFile
        output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
    }
}