Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not set unknown property 'outputFileName' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl

Getting the error

Could not set unknown property 'outputFileName' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.

using android studio 3.2.1

gradle 4.6

applicationVariants.all { variant ->
             variant.outputs.each { output ->
                 def fileName = "${project.name}_${output.baseName}-${variant.versionName}.apk"
                 outputFileName = new File(output.outputFile.parent, fileName).getName()
             }
         }
like image 216
Vatsal Desai Avatar asked Oct 16 '18 12:10

Vatsal Desai


1 Answers

you must use all

Use this code in your release biuld

android {
    //...
    buildTypes {

        debug {
        
        }
        release {
            android.applicationVariants.all { variant ->
                variant.outputs.all { output ->
                    def fileName = "${project.name}_${output.baseName}-${variant.versionName}.apk"
                    outputFileName = fileName
                }
            }
        }
    }

} 
}
like image 190
Radesh Avatar answered Oct 22 '22 10:10

Radesh