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

Android java.lang.NoClassDefFoundError: FakerService$$ExternalSyntheticLambda1 #90

Closed
vad99lord opened this issue Sep 24, 2021 · 3 comments
Labels
bug 🐞 Something isn't working core 🧬 Issue related to :core module good first issue 🔰 Good for newcomers
Milestone

Comments

@vad99lord
Copy link

I'm getting NoClassDefFoundError when creating Faker instance on android API 22.

java.lang.NoClassDefFoundError: io.github.serpro69.kfaker.FakerService$$ExternalSyntheticLambda1
        at io.github.serpro69.kfaker.FakerService.load(FakerService.kt:67)
        at io.github.serpro69.kfaker.FakerService.<init>(FakerService.kt:32)
        at io.github.serpro69.kfaker.Faker.<init>(Faker.kt:14)
        at io.github.serpro69.kfaker.Faker.<init>(Faker.kt:13)

The issue seems to be connected with calling defaultValues.merge() in private fun load(locale: String): Dictionary in the following place:

readCategory(it, "en").entries.forEach { category ->
                if (defaultValues.containsKey(category.key)) {
                    defaultValues.merge(category.key, category.value) { t, u -> t.plus(u) }
                } else defaultValues[category.key] = category.value
            }

I can see that it's not available in Kotlin API and Java API is used. According to android docs merge() is available since API 24 and I have no issues running the code on API 30.

I don't know if you are going to handle this android-specific case but i think it could be possible to update merging using Kotlin API only similar to this gist.

@serpro69 serpro69 added the bug 🐞 Something isn't working label Sep 26, 2021
@serpro69
Copy link
Owner

serpro69 commented Sep 26, 2021

Hi @vad99lord ,

I have no issues supporting android-specific cases, but reproducing issues on android platform is harder for me because I don't work with android apps.
Would you be willing to make a PR with the fix? If not, I can also add a fix, but then it could potentially involve some back-and-forth to test if it's actually working.
I also haven't had much time to work on side-projects since summer, but I hope I'll have more time from October, so I will definitely look into this if you don't want to try to fix this yourself and make a PR.
Let me know how you want to proceed with this.

@serpro69 serpro69 added core 🧬 Issue related to :core module good first issue 🔰 Good for newcomers labels Sep 26, 2021
@serpro69 serpro69 added this to the 1.8.0 milestone Oct 2, 2021
@serpro69
Copy link
Owner

serpro69 commented Oct 2, 2021

@vad99lord , I've removed usages of merge function from FakerService and this should be available in the latest 1.8.0-snapshot version.
Please test and let me know if it's working, or re-open the issue otherwise.

@vad99lord
Copy link
Author

vad99lord commented Oct 3, 2021

Hello @serpro69,

Sorry for the slow reply. The latest snapshot is working for me on both emulator and physical device with no problems. Thanks a lot for providing a quick fix to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working core 🧬 Issue related to :core module good first issue 🔰 Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants