airbnb / Showkase

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
https://medium.com/airbnb-engineering/introducing-showkase-a-library-to-organize-discover-and-visualize-your-jetpack-compose-elements-d5c34ef01095
Apache License 2.0
2.13k stars 107 forks source link

IllegalStateException on ShowkaseMultiPreviewCodegenMetadata #357

Closed yoviekaputra closed 1 year ago

yoviekaputra commented 1 year ago

Hi team, Thank you for making this library which is very helpful for me.

However, I would like to raise my findings regarding the message below:

error: java.lang.IllegalStateException: Unset annotation value without default should never happen: com.airbnb.android.showkase.annotation.ShowkaseMultiPreviewCodegenMetadata.previewName()
    at com.google.auto.common.AnnotationMirrors.getAnnotationValuesWithDefaults(AnnotationMirrors.java:99)
    at com.google.auto.common.AnnotationMirrors.getAnnotationElementAndValue(AnnotationMirrors.java:129)
    at com.google.auto.common.AnnotationMirrors.getAnnotationValue(AnnotationMirrors.java:114)
    at androidx.room.compiler.processing.javac.JavacAnnotationBoxKt.box(JavacAnnotationBox.kt:71)
    at androidx.room.compiler.processing.javac.JavacElement.getAnnotations(JavacElement.kt:57)
    at androidx.room.compiler.processing.InternalXAnnotated.getAnnotations(InternalXAnnotated.kt:46)
    at androidx.room.compiler.processing.XAnnotated.getAnnotation(XAnnotated.kt:147)
    at com.airbnb.android.showkase.processor.ShowkaseProcessor.processCustomAnnotationFromClasspath(ShowkaseProcessor.kt:201)
    at com.airbnb.android.showkase.processor.ShowkaseProcessor.processComponentAnnotation(ShowkaseProcessor.kt:103)
    at com.airbnb.android.showkase.processor.ShowkaseProcessor.process(ShowkaseProcessor.kt:84)
    at com.airbnb.android.showkase.processor.BaseProcessor.internalProcess(BaseProcessor.kt:96)
    at com.airbnb.android.showkase.processor.BaseProcessor.process(BaseProcessor.kt:64)
    at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt:90)
    at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:197)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1023)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$DiscoveredProcessors$ProcessorStateIterator.runContributingProcs(JavacProcessingEnvironment.java:859)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1265)
    at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1404)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1234)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90)
    at org.jetbrains.kotlin.kapt3.base.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:31)
    at org.jetbrains.kotlin.kapt3.base.Kapt.kapt(Kapt.kt:47)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.jetbrains.kotlin.gradle.internal.KaptExecution.run(KaptWithoutKotlincTask.kt:290)
    at org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction.execute(KaptWithoutKotlincTask.kt:236)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:66)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1$1.create(NoIsolationWorkerFactory.java:62)
    at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.lambda$execute$0(NoIsolationWorkerFactory.java:62)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:44)
    at org.gradle.workers.internal.AbstractWorker$1.call(AbstractWorker.java:41)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
    at org.gradle.workers.internal.AbstractWorker.executeWrappedInBuildOperation(AbstractWorker.java:41)
    at org.gradle.workers.internal.NoIsolationWorkerFactory$1.execute(NoIsolationWorkerFactory.java:59)
    at org.gradle.workers.internal.DefaultWorkerExecutor.lambda$submitWork$2(DefaultWorkerExecutor.java:205)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runExecution(DefaultConditionalExecutionQueue.java:187)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.access$700(DefaultConditionalExecutionQueue.java:120)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner$1.run(DefaultConditionalExecutionQueue.java:162)
    at org.gradle.internal.Factories$1.create(Factories.java:31)
    at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:249)
    at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:109)
    at org.gradle.internal.work.DefaultWorkerLeaseService.runAsWorkerThread(DefaultWorkerLeaseService.java:114)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

Actually, I use this library for multimodule. Each module has created a ShowkaseRootModule and also enabled skipPrivatePreviews in the module's gradle. But when I tried to build this project I encountered the above error. anyone help me regarding that?

yoviekaputra commented 1 year ago

fixed in PR i think: https://github.com/airbnb/Showkase/issues/357

oas004 commented 1 year ago

Hey,

Do you have a repo where I can reproduce this issue? :)

I saw in the PR above that you have used both @ShowkaseComposable and @Preview on the same composable. I don't know if that is the issue, but is there a use case that you need that? :)

Also, are you using KAPT or KSP with this library? :)

yoviekaputra commented 1 year ago

Hi @oas004 , thank you for your reply on this issue. I found the root cause of this issue, which is the Showkase did not support multiple preview annotations. btw, I implemented it like this:

@Preview("Light")
@Preview("Dark", uiMode = Configuration.UI_MODE_NIGHT_YES)
annotation class PreviewMultipleMode

@PreviewMultipleMode
@Composable
@ShowkaseComposable(name = "NestHeaderPreview", group = "NestHeader", skip = true)
fun ComponentPreview() {
    ...
}

when I build the project, such an error occurs

oas004 commented 1 year ago

@yoviekaputra What do you mean that showcase did not support multiple previews? Are you using an old version of Showkase? :)

yoviekaputra commented 1 year ago

on no, i sill using version 1.0.0-beta18, i gonna upgrade the version, thank you @oas004

yoviekaputra commented 1 year ago

solved in latest version, thank you