Copying APK file in Android Gradle project

If you can get the variant object associated with devDebug you could query it with getOutputFile().

So if you wanted to publish all variants you’d something like this:

def publish = project.tasks.create("publishAll")
android.applicationVariants.all { variant ->
  def task = project.tasks.create("publish${variant.name}Apk", Copy)
  task.from(variant.outputFile)
  task.into(buildDir)

  task.dependsOn variant.assemble
  publish.dependsOn task
}

Now you can call gradle publishAll and it’ll publish all you variants.

One issue with the mapping file is that the Proguard task doesn’t give you a getter to the file location, so you cannot currently query it. I’m hoping to get this fixed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)