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"))
}
}
More Related Contents:
- Why are there two build.gradle files in an Android Studio project?
- Android Studio Gradle issue upgrading to version 0.5.0 – Gradle Migrating From 0.8 to 0.9 – Also Android Studio upgrade to 0.8.1
- How to include a library module dependency in an Android Studio project?
- Android build gradle is too slow (Dependency Resolution)
- Android Studio: Add jar as library?
- Android Gradle plugin 0.7.0: “duplicate files during packaging of APK”
- “No cached version… available for offline mode.”
- Android- Error:Execution failed for task ‘:app:transformClassesWithDexForRelease’
- How to configure gradle to work “offline” (using cached dependencies)
- “Gradle Version 2.10 is required.” Error
- Android Studio Error “Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8”
- How to get current flavor in gradle
- Android Gradle Apache HttpClient does not exist?
- Gradle error: Minimum supported Gradle version is 3.3. Current version is 3.2
- Duplicate files copied (Android Studio 0.4.0) [duplicate]
- Autoincrement VersionCode with gradle extra properties
- How to create an Android Library Jar with gradle without publicly revealing source code?
- Gradle and Multi-Project structure
- Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to
- Android Studio: Resolving Duplicate Classes
- Conflict with dependency ‘com.android.support:support-annotations’. Resolved versions for app (23.1.0) and test app (23.0.1) differ
- no cached version available for offline mode
- Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve com.android.support:appcompat-v7:26.1.0
- Configuration with name ‘default’ not found. Android Studio
- Android studio 3.2.1 ArtifactResolveException: Could not resolve all artifacts for configuration ‘:classpath’
- Android Studio: how to generate signed APK using Gradle?
- Gradle error upgrading to Android Studio 3.0 Beta 1
- How to replace a string for a buildvariant with gradle in android studio?
- Android Studio: Re-download dependencies and sync project
- Can an AAR include transitive dependencies? [duplicate]