android tutorial - Delete apk automatically in Android | Developer android - android app development - android studio - android app developement



Delete "unaligned" apk automatically

  • If you don't need automatically generated apk files with unaligned suffix (which you probably don't), you may add the following code to build.gradle file:
// delete unaligned files
android.applicationVariants.all { variant ->
  variant.assemble.doLast {
    variant.outputs.each { output ->
        println "aligned " + output.outputFile
        println "unaligned " + output.packageApplication.outputFile

        File unaligned = output.packageApplication.outputFile;
        File aligned = output.outputFile
        if (!unaligned.getName().equalsIgnoreCase(aligned.getName())) {
            println "deleting " + unaligned.getName()
            unaligned.delete()
        }
    }
  }
}
click below button to copy code from our android learning website - android tutorial - team

Related Searches to Delete apk automatically in Android