VicMikhailau / MaskedEditText

It allows you to add a mask to EditText

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Runtime error with java 8 in java application

fabio-blanco opened this issue · comments

I'm working on a Java application configured with java 8 as both source and target compileOptions and with desugaring turned on.
When the application hits a point where a MaskedFormatter is been instantiated for the first time the application crashes with a NoClassDefFoundError in it's stacktrace:

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;

The cause is:

Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlin.jvm.internal.Intrinsics"

commented

Hi @fabio-blanco

Added new Release v.3.1.0 which includes new Gradle version (4.1.0) and other updates. In sample was added java 8 desugaring.

Check it, please.

commented

@fabio-blanco Please check sample. Desugaring is enabled there and crash don't reproduced.

@VicMikhailau It was a little tricky to find out what were you talking about when you've mentioned "sample" because in MaskedEditText source it is not clear what is sample and what is not. I suggest naming de sample directory as "sample" rather than "app".
And also my app is Java, not kotling, so your sample does not apply.
It turned out that the errors I've mentioned before were happening because I had no kotlin dependencies declared on the build.gradle of my app.
The changes I've made in my app in order to make your lib work made it a kotlin app. It seems to me a little bit extreme for using a lib but maybe that's just my fault. I don't know if it was possible to make it work without touching other dependencies declarations of a Java app.

commented

@fabio-blanco It's clear.
I can suggest to use old version (2.0.4) without kotlin migration. Maybe it is enough.

@VicMikhailau but than it won't have the last bug fixes and improvements.

commented

@fabio-blanco since version 2.0.4 main changes was android x and kotlin migration. Main logic is the same. I think for Java project it is enough.

@VicMikhailau As a final test, I was able to make it work with the last version by just placing this in my build.gradle file along with MaskedEdit dependence and without turning the hole project into Kotlin:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

I don't know though if that can led to other errors for some reason.

Note: As I've not tested version 2.0.4 of masked edit I don't know if it can crash in a Java app with desugaring turned on though.

Note 2: Maybe the solution pointed in the following link for kotlin dependency in pure Java Project can be a good implementation in MaskedEditText lib.

commented