You can use dependsOn for example (your app/build.gradle ):
apply plugin: 'com.android.application' apply plugin: 'com.google.firebase.firebase-crash' android { } dependencies { } task release task archiveRelease(type: Copy) { from './build/outputs/apk', './build/outputs/' into "../releases/${rootProject.ext.configuration.version_code}" include('app-release.apk', 'mapping/release/mapping.txt') rename('app-release.apk', "${rootProject.ext.configuration.package}_${rootProject.ext.configuration.version_name}_${rootProject.ext.configuration.version_code}.apk") } project.afterEvaluate { dependencyUpdates.dependsOn clean assembleRelease.dependsOn clean def publishApkRelease = project.tasks.getByName("publishApkRelease") publishApkRelease.dependsOn assembleRelease release.dependsOn publishApkRelease, firebaseUploadReleaseProguardMapping, archiveRelease }
I created a new task called release . It depends on publishApkRelease (comes from gradle-play-publisher ), firebaseUploadReleaseProguardMapping and archiveRelease . And publishApkRelease depends on assembleRelease .
In the first one, you simply call ./gradlew release and it will create your version of the release, upload the apk to the Google game, the mapping file in Firebase, and archive a copy of the apk and mapping file.
source share