Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Gradle assembleRelease file name

Is it possible to specify the filename of the generated *.apk through gradle? So that I automatically could get MyApp-1.0.0.apk instead of the default app-release.apk.

like image 418
just_user Avatar asked Oct 12 '25 21:10

just_user


1 Answers

You can do this by adding the following line to your build.gradle file inside the android{...} part:

android.applicationVariants.all { variant ->
    variant.outputFile = file("$project.buildDir/${defaultConfig.versionName}-${defaultConfig.versionCode}.apk")
}

Notes:

  1. Everything inside the file(...) is arbitrary, of course
  2. This code will output the *.apk to your project/module/build directory, no matter what path you've specified when Building the Signed APK.
  3. The output-file will take the Name and Version-Code from your build.gradle file.
  4. Android Studio may complain that it "cannot resolve symbol applicationVariants/defaultConfig" - ignore it. ;)
like image 74
reVerse Avatar answered Oct 14 '25 10:10

reVerse