geogson icon indicating copy to clipboard operation
geogson copied to clipboard

NoClassDefFoundError on Android API 23 and below

Open carlos-mg89 opened this issue 5 years ago • 1 comments

It's been a while that I'm receiving these errors, in real devices and emulators:

java.lang.NoClassDefFoundError: com.github.filosganga.geogson.util

This happens, in my case, when I try to read a Geometry, using Gson:

var geometry = gson.fromJson(reader, Geometry::class.java)

Although I have correctly set up the Gson client:

val gson = GsonBuilder()
                .registerTypeAdapterFactory(JtsAdapterFactory())
                .registerTypeAdapterFactory(GeometryAdapterFactory())
                .create()

This doesn't happen in Android 24 or higher.

I'm using Java 1.8 and compileSdkVersion 29:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

Any help will be more than appreciated.

carlos-mg89 avatar Dec 30 '19 11:12 carlos-mg89

Version 1.2.21 seems to be the only one working nicely on Android API 23 and lower, at least if using Java 1.8. Hope this is useful to someone.

implementation "com.github.filosganga:geogson-core:1.2.21"
implementation "com.github.filosganga:geogson-jts:1.2.21"

I believe this library would need an update. Is someone interested? I could give it a try by creating a fork.

carlos-mg89 avatar Dec 30 '19 14:12 carlos-mg89