Skip to content

Instantly share code, notes, and snippets.

@gunhansancar
Last active May 6, 2019 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gunhansancar/a5883b7e218d5bd1ca44 to your computer and use it in GitHub Desktop.
Save gunhansancar/a5883b7e218d5bd1ca44 to your computer and use it in GitHub Desktop.
This is a sample build.gradle file for your android libraries to change their artifact file names. You can find more information on http://gunhansancar.com/how-to-change-apk-file-name-in-android/
//apply plugin: 'com.android.library' //uncomment this line for android libraries
//apply plugin: 'com.android.application' //uncomment this line for android applications
def renameArtifact(variant, defaultConfig) {
variant.outputs.each { output ->
def formattedDate = new Date().format('yyyyMMddHHmmss')
def fullName = output.outputFile.name
def projectName = fullName.substring(0, fullName.indexOf('-'))
output.outputFile = new File(
(String) output.outputFile.parent,
(String) output.outputFile.name.replace(projectName, "${projectName}-${defaultConfig.versionName}-${formattedDate}"))
}
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
//include this line for your android libraries
//libraryVariants.all { variant -> renameArtifact(variant, defaultConfig) }
//include this line for your android applications
//applicationVariants.all { variant -> renameArtifact(variant, defaultConfig) }
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//include your dependencies
}
@oporto723
Copy link

Ñ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment