VicMikhailau / MaskedEditText

It allows you to add a mask to EditText
Apache License 2.0
284 stars 50 forks source link

Runtime error with java 8 in java application #27

Closed fabio-blanco closed 3 years ago

fabio-blanco commented 3 years ago

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"

VicMikhailau commented 3 years ago

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.

fabio-blanco commented 3 years ago

Hi @VicMikhailau

Same error.

VicMikhailau commented 3 years ago

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

fabio-blanco commented 3 years ago

@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.

VicMikhailau commented 3 years ago

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

fabio-blanco commented 3 years ago

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

VicMikhailau commented 3 years ago

@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.

fabio-blanco commented 3 years ago

@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.

VicMikhailau commented 3 years ago

@fabio-blanco thanks.