AniTrend / android-emojify

An android project to convert short codes, emoticons, html entities, emoticons to emoji and vice-versa
https://anitrend.github.io/android-emojify
Apache License 2.0
25 stars 12 forks source link

Dependecy missing in 1.7.1 #178

Closed yoobi closed 9 months ago

yoobi commented 9 months ago

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 ?

wax911 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

Tell me what you think about my PR :)

wax911 commented 9 months ago

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

yoobi commented 9 months ago

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

wax911 commented 9 months ago

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 commented 9 months ago

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

wax911 commented 9 months ago

Feel free to merge the PR whenever you're ready \πŸ˜ƒ/

yoobi commented 9 months ago

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

Screenshot 2024-02-21 at 21 20 32