Lilly
05/24/2022, 8:06 PMVariant API
, e.g. iterating over build variants but it does not call the proper all function:
applicationVariants.all { variant ->
println(variant.name)
}
It uses the all function from Iterable
which expects a boolean return type. I would like to change the outputFileName
of all variants. Any ideas how to specify the correct function in this case?
EDIT: upsi, I have to remove the variant ->
Daniel B Duval
05/24/2022, 10:12 PMandroid
block:
androidComponents {
onVariants(selector().all(), { variant ->
def targetDirectory = "outputs/apk/"
def copy = tasks.register("copy${variant.getName().capitalize()}Apks", Copy) {
from { variant.artifacts.get(SingleArtifact.APK.INSTANCE) }
include "*.apk"
into project.layout.buildDirectory.dir(targetDirectory)
}
afterEvaluate {
tasks.named("create${variant.getName().capitalize()}ApkListingFileRedirect").configure( {
it.dependsOn(copy)
})
tasks.withType(PackageApplication.class).named("package${variant.getName().capitalize()}").configure {
finalizedBy(copy)
copy.get().dependsOn(it)
}
}
})
}
Lilly
05/25/2022, 11:56 AMandroidComponents {
onVariants { variant ->
val targetDirectory = "outputs2/apk/"
val copyTask = tasks.register<Copy>("copy${variant.name.capitalize()}Apks") {
// Get apk folder
println("apkArtifact: ${variant.artifacts.get(SingleArtifact.APK)}.")
from(variant.artifacts.get(SingleArtifact.APK))
include("lachen.apk")
into(project.layout.buildDirectory.dir(targetDirectory))
}
afterEvaluate {
tasks.named("create${variant.name.capitalize()}ApkListingFileRedirect").configure {
dependsOn(copyTask)
}
tasks.named("package${variant.name.capitalize()}").configure {
finalizedBy(copyTask)
copyTask.get().dependsOn(this)
}
}
}
Daniel B Duval
05/25/2022, 3:39 PMbuild/outputs2/apk/
there? In my example, I was putting into the normal build/outtputs/apk
folder, so I’m not sure if the folder will be created
• Under /build/apk/${valriant}/${buildType}
what are the APK names.
We have multiple flavors and build types, but only build one at a time, thus we use include "*.apk"
as we just copy the apk that is there up to outputs/apkLilly
05/25/2022, 3:40 PMDaniel B Duval
05/25/2022, 3:43 PM${App}-${variant}-${buildType}.apk
Lilly
05/25/2022, 3:45 PM> Task :dcintern:packageDebug
> Task :dcintern:copyDebugApks NO-SOURCE
> Task :dcintern:createDebugApkListingFileRedirect
> Task :dcintern:assembleDebug
Maybe NO-SOURCE is here a problem.
We have multiple flavors and build typesI have only debug and release.
• Underafter running build task I have the following files there: outputs/apk/debug/dcintern-debug.apkwhat are the APK names./build/apk/${valriant}/${buildType}
Lilly
05/25/2022, 3:46 PMtargetDirectory = "outputs/apk/"
Daniel B Duval
05/25/2022, 3:52 PMlachen.apk
as the file pattern to match to copy.Daniel B Duval
05/25/2022, 3:53 PM*.apk
should take any file in the format of *apk
and move it to outputs/apk
Lilly
05/25/2022, 3:53 PM${App}-${variant}-${buildType}.apk
Daniel B Duval
05/25/2022, 3:54 PM{app}-{buildtype}.apk
Lilly
05/25/2022, 3:55 PM${App}-${variant}-${buildType}-v${versionCode}.apk
Lilly
05/25/2022, 3:56 PMDaniel B Duval
05/25/2022, 4:09 PMLilly
05/25/2022, 4:16 PMDaniel B Duval
05/25/2022, 8:42 PMDaniel B Duval
05/25/2022, 8:43 PMXavier Ducrohet
05/26/2022, 2:27 AM