Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark 中添加 booster 编译失败 #454

Open
woxin123 opened this issue Mar 25, 2024 · 0 comments
Open

Benchmark 中添加 booster 编译失败 #454

woxin123 opened this issue Mar 25, 2024 · 0 comments

Comments

@woxin123
Copy link

Please provide the following informations.

  • System version

  • Java version

  • Gradle version

  • Android Gradle plugin version

  • Booster version

  • Stack traces

Caused by: java.util.NoSuchElementException: Collection contains no element matching the predicate.
	at com.didiglobal.booster.gradle.AGPInterface$DefaultImpls.getVariant(AGPInterface.kt:277)
	at com.didiglobal.booster.android.gradle.v7_0.V70.getVariant(V70.kt:70)
	at com.didiglobal.booster.gradle.TransformInvocationKt.getVariant(TransformInvocation.kt:22)
	at com.didiglobal.booster.gradle.TransformInvocationKt.getApplicationId(TransformInvocation.kt:51)
	at com.didiglobal.booster.gradle.BoosterTransformInvocation.<init>(BoosterTransformInvocation.kt:99)
	at com.didiglobal.booster.gradle.BoosterTransform.transform(BoosterTransform.kt:50)
	at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:284)
	at com.android.build.gradle.internal.profile.NoOpAnalyticsService.recordBlock(NoOpAnalyticsService.kt:72)
	at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:242)
	at jdk.internal.reflect.GeneratedMethodAccessor3428.invoke(Unknown Source)

benchmark 的项目是 library,但是在 Transform 获取 variant 的时候没有对于 library 没有判断是否是测试。

com.didiglobal.booster.gradle.AGPInterface#getVariant

val TransformInvocation.variant: BaseVariant
        get() = project.getAndroid<BaseExtension>().let { android ->
            this.context.variantName.let { variant ->
                when (android) {
                    is AppExtension -> when {
                        variant.endsWith("AndroidTest") -> android.testVariants.single { it.name == variant }
                        variant.endsWith("UnitTest") -> android.unitTestVariants.single { it.name == variant }
                        else -> android.applicationVariants.single { it.name == variant }
                    }
                    is LibraryExtension -> android.libraryVariants.single { it.name == variant }
                    else -> TODO("variant not found")
                }
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant