I have two product flavors, `free` and `pro` . How...
# compose
s
I have two product flavors,
free
and
pro
. How can I make a different composable with the same name for each flavor?
d
Why do you want the same name? I guess you could use a local.
n
Guessing you could simply make the same composable function in your two different product flavor directories.
app/src/free/java
and
app/src/pro/java
something like in this image:
s
@Dominaezzz I need to show an ad in
free
but not in
pro
. The ad libraries are not present in
pro
so I can't have the same file for both.
@Neal Sanche I tried that but it crashed:
Copy code
java.lang.NoSuchMethodError: No static method CustomBackHandler(Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V in class Lcom/myapp/ui/CustomBackHandlerKt; or its super classes (declaration of 'com.myapp.ui.CustomBackHandlerKt' appears in /data/app/~~vsWTw2NQ7h9zOznCX9tfSg==/com.myapp-AUa0BZIiTevSu2bFJpYcrw==/base.apk!classes8.dex)
n
I tried just a simple case of setting up the Greeting composable in the two different source sets. That worked for me. Not sure why CustomBackHandler is involved in your crash. Perhaps Free and Pro trying to reference code in Main?
s
Ah I got it. I had the same name as
CustomBackHandler
for my
BaseBackHandler
file in main. Thanks for the help!
👍 1