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

Can't update from beta08 to beta09 #203

Closed
davidvavra opened this issue Jan 11, 2022 · 17 comments
Closed

Can't update from beta08 to beta09 #203

davidvavra opened this issue Jan 11, 2022 · 17 comments

Comments

@davidvavra
Copy link

Hi,
when I try to update from beta08 to beta09 (or beta10), the build fails with:

Unresolved reference: getBrowserIntent

(the extension function which does this is not generated)

I can't reproduce it on my open-source project, only in my work project.

I tried updating Kotlin to 1.5.31 and Compose to 1.0.4, but it didn't help. Any ideas what I can try to debug this?

@vinaygaba
Copy link
Collaborator

vinaygaba commented Jan 11, 2022

So the new updates work on your open source project? 🤔 Can you double check whether the new updates are indeed working by doing a clean first.

@davidvavra
Copy link
Author

Yes, in open source project the update works with no issues. I didn't even have to update Compose & Kotlin version. I tried clean build as well.

Can I get somehow logs which would tell why it was not generated? I tried --info or --debug but couldn't find anything useful there.

@vinaygaba
Copy link
Collaborator

Can you tell me if you have a dependency on this artifact - androidx.compose.ui:ui-tooling-preview. If not, can you add it and try it.

@davidvavra
Copy link
Author

Yeah, it was a transitive dependency of something. I tried to also add it explicitly, but it didn't help.

@vinaygaba
Copy link
Collaborator

vinaygaba commented Jan 11, 2022

Does it have any @ Previews or @ShowkaseComposables?

@davidvavra
Copy link
Author

Many @previews in multiple modules. No @ShowkaseComposables. It works in beta08, there are no code changes except updating library versions.

@vinaygaba
Copy link
Collaborator

beta09 introduced ksp support to Showkase so it involved a big refactor, although it shouldn't have changed any logic or setup if you continue using ksp - https://github.com/airbnb/Showkase/releases/tag/1.0.0-beta09

Wondering if there are any differences in how things are setup between your projects? I'm going to take a stab and will try to repro it.

@davidvavra
Copy link
Author

I was wondering what's different in our project. It's hard to tell, it's a large codebase.

But I had a suspicion about one difference which caused issues in the past
The @ShowkaseRoot is in app module, which is a top-level module. It has a dependency to all feature modules. But it contains no UI, that's all in feature modules. So it didn't contain any @Previews as well. So I added a dummy composable and @Preview in the app module. The app can compile now! But the Showkase browser shows only this one preview from app module, it doesn't show anything from the feature modules. Any ideas?

@vinaygaba
Copy link
Collaborator

Can you look at the classes that Showkase will generated (under build > generated > kapt). There should be files in the app module and the feature modules as well. That should have clues about what is being identified.

@davidvavra
Copy link
Author

Here is related generated code from the 'app' module:

public class ShowkaseMetadataShowkase {
  @ShowkaseCodegenMetadata(
    showkaseName = "Test",
    showkaseGroup = "Default Group",
    packageName = "com.jll.jet.app.showkase",
    packageSimpleName = "showkase",
    showkaseElementName = "TestPreview",
    insideObject = false,
    insideWrapperClass = false,
    showkaseKDoc = "",
    showkaseMetadataType = "COMPONENT",
    isDefaultStyle = false,
    showkaseWidthDp = -1,
    showkaseHeightDp = -1
  )
  public fun TestPreview(): Unit {
  }
}
@ShowkaseRootCodegen(
  numComposablesWithoutPreviewParameter = 1,
  numComposablesWithPreviewParameter = 0,
  numColors = 0,
  numTypography = 0
)
public class ShowKaseSetupCodegen : ShowkaseProvider {
  public val componentList: List<ShowkaseBrowserComponent> =
      mutableListOf<ShowkaseBrowserComponent>(
        ShowkaseBrowserComponent(
            group = "Default Group",
            componentName = "Test",
            componentKDoc = "",
            componentKey = """com.jll.jet.app.showkase_null_DefaultGroup_Test_null""",
            isDefaultStyle = false,
            widthDp = -1,
            heightDp = -1,
            component = @Composable { TestPreview() })
      )

  public val colorList: List<ShowkaseBrowserColor> = listOf<ShowkaseBrowserColor>()

  public val typographyList: List<ShowkaseBrowserTypography> = listOf<ShowkaseBrowserTypography>()

  public override fun getShowkaseComponents() = componentList

  public override fun getShowkaseColors() = colorList

  public override fun getShowkaseTypography() = typographyList
}
/**
 * Helper function that's autogenerated and gives you an intent to start the ShowkaseBrowser.
 */
public fun Showkase.getBrowserIntent(context: Context): Intent {
    val intent = Intent(context, ShowkaseBrowserActivity::class.java)
    intent.putExtra("SHOWKASE_ROOT_MODULE", "com.jll.jet.app.showkase.ShowKaseSetup")
    return intent
}

/**
 * Helper function that's give's you access to Showkase metadata. This contains data about the
 * composables, colors and typography in your codebase that's rendered in showakse.
 */
public fun Showkase.getMetadata(): ShowkaseElementsMetadata {
    try {
      val showkaseComponentProvider =
          Class.forName("com.jll.jet.app.showkase.ShowKaseSetupCodegen").newInstance() as
          ShowkaseProvider
      return showkaseComponentProvider.metadata()
    } catch(exception: ClassNotFoundException) {
      error("The class wasn't generated correctly. Make sure that you have setup Showkase correctly by following the steps here - https://github.com/airbnb/Showkase#Installation.")
    }
}

The feature modules have generated metadata for their own composables. But somehow it's not connected together in the app module.

@vinaygaba
Copy link
Collaborator

@davidvavra hmm the only way this can happen is if the app module does not depend on the feature modules 🤔

@davidvavra
Copy link
Author

It does depend on feature modules and it works with beta08. Only solution I can think of now is to fork the library at beta08 and apply the fix from beta10 there :(

@vinaygaba
Copy link
Collaborator

I'm trying to repro so that I can potentially fix it. Were you using kapt or ksp?

@davidvavra
Copy link
Author

kapt

@zoey-juan
Copy link

Same issue in our project. beta08 works but not beta09/beta10. I have tested with kapt/ksp, both are not working.

@vinaygaba
Copy link
Collaborator

Duplicate issue here - #213
I finally have some time today to investigate this.

@vinaygaba
Copy link
Collaborator

This PR should fix it - #216

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

3 participants