geogson
geogson copied to clipboard
NoClassDefFoundError on Android API 23 and below
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.
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.