Skip to content

Commit

Permalink
Fix using universal apk when abi-splits are present (#3)
Browse files Browse the repository at this point in the history
* fix failing to use universalApk when abi-splits are present

---------

Co-authored-by: Vlad Krasnikov <vkrasnikov@alfabank.ru>
  • Loading branch information
jarl-balling and Vlad Krasnikov authored Sep 21, 2024
1 parent 84d8f12 commit 50baac3
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.malinskiy.marathon.gradle.task

import com.android.build.api.variant.BuiltArtifacts
import com.android.build.api.variant.VariantOutputConfiguration
import com.malinskiy.marathon.config.serialization.ConfigurationFactory
import com.malinskiy.marathon.config.vendor.android.AndroidTestBundleConfiguration
import com.malinskiy.marathon.gradle.GradleAndroidTestBundle
Expand Down Expand Up @@ -83,19 +84,19 @@ open class GenerateMarathonfileTask @Inject constructor(objects: ObjectFactory)
return bundles.map {
when(it) {
is GradleAndroidTestBundle.ApplicationWithTest -> {
val artifactLoader = it.artifactLoader.get()
val artifacts: BuiltArtifacts =
val artifactLoader = it.artifactLoader.get()
val artifacts: BuiltArtifacts =
artifactLoader.load(it.apkFolder.get()) ?: throw RuntimeException("No application artifact found")
when {
artifacts.elements.size > 1 -> throw UnsupportedOperationException(
"The Marathon plugin does not support abi splits for app APKs, " +
"but supports testing via a universal APK. "
+ "Add the flag \"universalApk true\" in the android.splits.abi configuration."
)

artifacts.elements.isEmpty() -> throw UnsupportedOperationException("No artifacts for variant $flavorName")
}
val application = File(artifacts.elements.first().outputFile)
val validArtifact = artifacts.elements.find { builtArtifact ->
builtArtifact.outputType == VariantOutputConfiguration.OutputType.SINGLE // when there are no splits
} ?: artifacts.elements.find { builtArtifact ->
builtArtifact.outputType == VariantOutputConfiguration.OutputType.UNIVERSAL // when universal apk is present
} ?: throw UnsupportedOperationException(
"The Marathon plugin does not support abi splits for app APKs, " +
"but supports testing via a universal APK. "
+ "Add the flag \"universalApk true\" in the android.splits.abi configuration."
)
val application = File(validArtifact.outputFile)
val testArtifactsLoader = it.testArtifactLoader.get()
val testArtifacts =
testArtifactsLoader.load(it.testApkFolder.get()) ?: throw RuntimeException("No test artifacts for variant $flavorName")
Expand Down

0 comments on commit 50baac3

Please sign in to comment.