简体   繁体   中英

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()
             }
         }

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
                }
            }
        }
    }

} 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM