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

Library doesn't work with multi-module project #29

Open
graisVictory opened this issue Aug 9, 2022 · 4 comments
Open

Library doesn't work with multi-module project #29

graisVictory opened this issue Aug 9, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@graisVictory
Copy link

Hi! Thanks for all your work! Library doesn't work with multi-module project because it generates the same classes with same packages for each module :(

@gobbletsit
Copy link
Contributor

Hi @graisVictory ,

It would be great if you can specify in which way the library has been used in your case. I've double tested the library in multi module projects and all seems to be working as expected. There might be some other issue we're not aware of that is causing problems in your setup.

We would appreciate a bit more information about the issue you're experiencing so we can act accordingly :)

Kind regards

@stjepanbanek stjepanbanek added the enhancement New feature or request label Oct 13, 2022
@stjepanbanek stjepanbanek self-assigned this Oct 13, 2022
@howardtamhk
Copy link
Contributor

Hi @stjepanbanek, I have encounter issues with multi-modules project as well.

There are two issues.

  1. When there are multi modules depending on the library. It will have error in mergeLibDex
Caused by: com.android.tools.r8.internal.f: Type com.infinum.jsonapix.JsonXExtensions$format$1 is defined multiple times: .....

Seems to me, that's caused by there is a JsonXExtension.kt for each module. And they all contains property format.

  1. ClassA and ClassB are in different modules and instance of ClassB is property of ClassA.

In :moduleA

@Serializable
@JsonApiX(type = "classA")
data class ClassA(
   @HasOne(type="classB")
    val classB: ClassB
)

In :moduleB

@Serializable
@JsonApiX(type = "classB")
data class ClassB(
    val foo: String
)

When compiling :moduleA, an error will be thrown.

JsonXExtensions.kt: (): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
OtherClass.toResourceObject()
AnotherClass.toResourceObject()

Please let me know if I have done anything incorrect. Thanks!

@stjepanbanek
Copy link
Contributor

Hi @howardtamhk!

Can you share your dependency setup from the project and module level build.gradle files?

I suspect you might be right about JsonXExtensions being generated twice.

I will test myself when I get the chance. If I can reproduce the issue, I will add it to the planned fixed for the next release.

Thanks for using the lib and the feedback! And for the patience :)

@howardtamhk
Copy link
Contributor

Thanks @stjepanbanek!

I've created a quick sample https://github.com/howardtamhk/JsonApiXTest. Let me know if you cannot reproduce the issues.

@thisAAY thisAAY self-assigned this May 24, 2023
@thisAAY thisAAY assigned DrakslerT and unassigned thisAAY and stjepanbanek Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

6 participants