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 build the project if app is a root module #188

Closed
davidvavra opened this issue Oct 27, 2021 · 13 comments
Closed

Can't build the project if app is a root module #188

davidvavra opened this issue Oct 27, 2021 · 13 comments

Comments

@davidvavra
Copy link

Hi, we have a multi-module project. Previously I had one module 'main' with some submodules containing previews and it worked. But we also have some modules which are not dependencies of 'main' module. Only the top-level 'app' module has a dependency to all modules. I tried to move @ShowkaseRoot to the 'app' module.

Now building project fails with this exception:

Caused by: java.lang.NullPointerException
	at com.airbnb.android.showkase.processor.ShowkaseProcessor.init(ShowkaseProcessor.kt:61)
	at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.init(incrementalProcessors.kt:41)
	at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.init(annotationProcessing.kt:197)

Any ideas what might help?

@vinaygaba
Copy link
Collaborator

Does this module have the compose dependencies set up? It looks like you might not have the compose dependencies in the new module where you moved this root to.

@vinaygaba
Copy link
Collaborator

Wanted to check again and see if you were able to resolve this issue with what I recommended

@davidvavra
Copy link
Author

I didn't get to it yet. But the 'app' module doesn't have Compose dependencies, so it's most likely the cause.

@vinaygaba
Copy link
Collaborator

Yeah that checks out as that's what the stack trace was pointing to as well.

@davidvavra
Copy link
Author

Hi @vinaygaba. I have added compose dependencies to the app module and the error is gone and I can build the project.

However when I start the ShowKase activity, it crashes with this exception:

    java.lang.NoSuchMethodError: No direct method <init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function0;Ljava/lang/String;ZLjava/lang/Integer;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V in class Lcom/airbnb/android/showkase/models/ShowkaseBrowserComponent; or its super classes (declaration of 'com.airbnb.android.showkase.models.ShowkaseBrowserComponent' appears in /data/app/com.jll.mya.dev-IRMZ1MPZPHA3rYtalM9CxA==/base.apk!classes13.dex)
        at com.jll.jet.app.showkase.ShowKaseSetupCodegen.<init>(ShowKaseSetupCodegen.kt:41)
        at java.lang.Class.newInstance(Native Method)
        at com.airbnb.android.showkase.ui.ShowkaseBrowserActivity.getShowkaseProviderElements(ShowkaseBrowserActivity.kt:61)
        at com.airbnb.android.showkase.ui.ShowkaseBrowserActivity.access$getShowkaseProviderElements(ShowkaseBrowserActivity.kt:19)
        at com.airbnb.android.showkase.ui.ShowkaseBrowserActivity$onCreate$1.invoke(ShowkaseBrowserActivity.kt:31)
        at com.airbnb.android.showkase.ui.ShowkaseBrowserActivity$onCreate$1.invoke(ShowkaseBrowserActivity.kt:26)

Any ideas?

@davidvavra
Copy link
Author

Any updates @vinaygaba? It's currently blocking usage of the library and I don't know how to proceed (only to for library and modify it somehow). I promise that if this is solved, I will write a blogpost a promote this library :)

@vinaygaba
Copy link
Collaborator

@davidvavra I was on vacation, sorry about th delay! These kind of errors are usually when you are using a different version of kotlin/Compose than what the library is using. Could you tell me which version of compose you are trying it with?

@vinaygaba
Copy link
Collaborator

vinaygaba commented Nov 30, 2021

This library is using 1.0.3. I can probably publish the library with the latest version if compose of that helps. Unfortunately this is a Compose related nuance as they build against specific versions of Kotlin

@davidvavra
Copy link
Author

I checked and we are using same versions - Compose 1.0.3 and Kotlin 1.5.30. It was working when the root module was a nested module and not 'app' module, so I think the problem is somewhere else.

@davidvavra
Copy link
Author

@vinaygaba I spent hours debugging dependencies and then I found out this was missing:

buildFeatures {
        compose = true
}

🤦‍♂️

So the issues is solved, but I think documentation should be improved (with dependency requirements for root module).

@vinaygaba
Copy link
Collaborator

This is actually a compose requirement and has very little to do with Showkase. Since it's a Jetpack Compose only library, the assumption is that Compose is setup to work correctly in your codebase.

@davidvavra
Copy link
Author

davidvavra commented Dec 7, 2021

Our case is that all UI is in feature modules and those modules have correct Compose dependencies. We try to keep app module minimalistic, just Application object and necessary library setup. There is no UI so no Compose dependencies. But the app module is the only one with dependencies to all feature modules, so it needs to be root module for Showkase. And it wasn't obvious to me it also needs all the Compose setup.

@vinaygaba
Copy link
Collaborator

Sounds like I can maybe add this detail in the setup to be explicit that Compose dependencies were needed. I'm glad it resolved for you though! Excited for you to try it out :)

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

2 participants