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

Dependecy missing in 1.7.1 #178

Closed
yoobi opened this issue Feb 12, 2024 · 10 comments · Fixed by #179
Closed

Dependecy missing in 1.7.1 #178

yoobi opened this issue Feb 12, 2024 · 10 comments · Fixed by #179
Labels

Comments

@yoobi
Copy link
Contributor

yoobi commented Feb 12, 2024

Description of Bug

Kotlinxserialization is missing in 1.7.1 package which cause the emojiManager to fail loading and parsing the emoji.json
Here is the logs:

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/serialization/json/JsonKt;
	at io.wax911.emojify.initializer.EmojiInitializer.initEmojiData(EmojiInitializer.kt:44)
	at io.wax911.emojify.initializer.EmojiInitializer.initEmojiData$default(EmojiInitializer.kt:42)
	at io.wax911.emojify.initializer.EmojiInitializer.create(EmojiInitializer.kt:58)
	at io.wax911.emojify.initializer.EmojiInitializer.create(EmojiInitializer.kt:30)
	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)
	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
	at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
	at android.content.ContentProvider.attachInfo(ContentProvider.java:2404)
	at android.content.ContentProvider.attachInfo(ContentProvider.java:2374)
	at android.app.ActivityThread.installProvider(ActivityThread.java:7459)
	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6976)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6747)
	at android.app.ActivityThread.access$1500(ActivityThread.java:256)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7870)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlinx.serialization.json.JsonKt" on path: DexPathList[[zip file "/data/app/~~NlkoSJsQPk2J_xmEXqaLdg==/io.wax911.emoji.sample-8O505Ni-SFZUXtbtx4Xlug==/base.apk"],nativeLibraryDirectories=[/data/app/~~NlkoSJsQPk2J_xmEXqaLdg==/io.wax911.emoji.sample-8O505Ni-SFZUXtbtx4Xlug==/lib/arm64, /system/lib64, /system_ext/lib64]]
	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
	... 22 more

Reproduction Steps

Implement the library via jitpack and start the app.

To solve

In order to solve this issue there are multiple solution I have in mind:

NB: Also any reason why minSdk is 23 ?

@yoobi yoobi added the bug label Feb 12, 2024
@wax911
Copy link
Member

wax911 commented Feb 14, 2024

Thanks @yoobi great suggestion, odd how I just never considered making the dependency transitive due to how I already used it in my projects 😆

Providing custom parser should be possible since there's a contract for EmojiManager https://github.com/AniTrend/android-emojify/blob/develop/emojify/src/main/kotlin/io/wax911/emojify/manager/IEmojiManager.kt is a public API and the parser applies extension on it, what exact usecase did you have in mind

NB: Also any reason why minSdk is 23 ?
To be honest no real reason, it was mostly motivated by the Android API Distribution charts

@yoobi
Copy link
Contributor Author

yoobi commented Feb 14, 2024

I was thinking of something like

interface IEmojiDeserializer {
    /**
     * Decodes the given [inputStream] to an object of type List<[Emoji]>
     */
    fun decodeFromStream(inputStream: InputStream): List<Emoji>
}
interface IEmojiManager {
   ....

   val serializer: IEmojiDeserializer
}

So that each user can implement their own serializer (in my project I often user Moshi, but other might prefer gson etc....)

Also would it be possible to revert the minSdk to 21 ?

@yoobi
Copy link
Contributor Author

yoobi commented Feb 14, 2024

I have managed a way to do it simply but there would be a breaking change, user will need to declare in the manifest of their app the EmojiInitializer

I'll provide a PR

@yoobi
Copy link
Contributor Author

yoobi commented Feb 18, 2024

Tell me what you think about my PR :)

@wax911 wax911 linked a pull request Feb 19, 2024 that will close this issue
3 tasks
@wax911
Copy link
Member

wax911 commented Feb 19, 2024

Hey, sorry for getting back to you after so long. I haven't been well.

@yoobi
Copy link
Contributor Author

yoobi commented Feb 19, 2024

No worries ! This PR can wait for you to feel better

@wax911
Copy link
Member

wax911 commented Feb 20, 2024

Thanks, feeling a lot better now! Thank you for taking the time to implement these changes and addressing the many comments 😄 appreciate the help

@yoobi
Copy link
Contributor Author

yoobi commented Feb 20, 2024

Glad to hear you're feeling better :)
No worries ! It was fun, I'll rename the abstract class tomorrow

@wax911
Copy link
Member

wax911 commented Feb 21, 2024

Feel free to merge the PR whenever you're ready \😃/

@yoobi
Copy link
Contributor Author

yoobi commented Feb 21, 2024

Thanks ! It seems I don't have the right to merge the pull request

Screenshot 2024-02-21 at 21 20 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants