Comments (8)
I'll try to replicate your setup. In the meantime I would try:
- using clean before the build
- using the java8 annotation processor instead
So try replacing
kapt "com.dslplatform:dsl-json-processor:1.7.3"
with
kapt "com.dslplatform:dsl-json-java8:1.7.3"
from dsl-json.
I always do a Rebuild or (Clean -> Rebuild).
I've tried using the java8 annotation processor, but doing so gets me on a whole different path of errors:
Annotation processors must be explicitly declared now.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- dsl-json-java8-1.7.3.jar (com.dslplatform:dsl-json-java8:1.7.3)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
so then I can either change kapt "com.dslplatform:dsl-json-java8:1.7.3"
to annotationProcessor "com.dslplatform:dsl-json-java8:1.7.3"
, or do something like:
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false //(or true)
}
}
}
}
but then I get this desugaring error:
https://gist.github.com/dvhp/b9daf7000e1db075cde3d01678ab7d88
so I add the compileOptions:
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
And finally i get this:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/json/bind/Jsonb
https://gist.github.com/dvhp/468aecdb625a1078fbf18de01f0ff88f
If you want I can provide more detailed gradle logs and/or a sample project.
I've also tried 2 different versions of kotlin and kotlin-gradle-plugin - 1.2.31 and 1.2.40
from dsl-json.
Try adding explicit jsonb dependency
javax.json.bind:javax.json.bind-api:1.0
Currently it's provided, but I guess I should make it compile time ;( https://github.com/ngs-doo/dsl-json/blob/master/java8/pom.xml#L22
from dsl-json.
As for that annotation procesor error in never versions gradle now expects
annotationProcessor 'com.dslplatform:dsl-json-java8:1.7.3'
instead of apt
from dsl-json.
after adding the jsonb dependency, I'm getting:
:app:transformClassesWithStackFramesFixerForDebug
Exception in thread "main" java.lang.IllegalArgumentException: Type without superclass: module-info
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:191)
Full trace here:
https://gist.github.com/dvhp/a2f985cfbfe1f57b6ba6eefbb2ee2a5f
build.gradle looks like this:
android {
...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
...
implementation "javax.json.bind:javax.json.bind-api:1.0"
annotationProcessor "com.dslplatform:dsl-json-java8:1.7.3"
implementation "com.dslplatform:dsl-json-java8:1.7.3"
}
...
On a side note: Any chance of seeing a "converter" (like gson or moshi) for retrofit using dsl-json? Is it even possible to do it? I would happily work on it with some indication in the right direction.
from dsl-json.
I managed to get the build working. I removed the jsonb dependency implementation "javax.json.bind:javax.json.bind-api:1.0"
and added android.enableD8.desugaring = true
in gradle.properties
. Everything else is the same as in the .gradle file from the previous post.
So I guess this issue can be closed.
However I do have another question if someone is willing to help me out: I'm basically trying to deserialize a big .json file (this one) and insert the data into an sqlite table. And I'm wondering what combination of annotated classes and dsl-json reader would give the best performance. Since this file is formatted like an array of objects [{}, {}], I cannot use the class structure mentioned in the first post and I don't think it would be ok to deserialize into something like a List<...>. I have not managed to find an example dealing with large json list streaming.
from dsl-json.
I'll look into creating Android example for Kotlin anyway, so let's leave this open until I do.
As for the second thing... I think it's fine to deserialize such input into some list... there is even specialized API for that: https://github.com/ngs-doo/dsl-json/blob/master/library/src/main/java/com/dslplatform/json/DslJson.java#L1692
If you wish to avoid having all instances in memory you can use the iterate over API: https://github.com/ngs-doo/dsl-json/blob/master/library/src/main/java/com/dslplatform/json/DslJson.java#L2042
from dsl-json.
I've added Android Kotlin example: https://github.com/ngs-doo/dsl-json/tree/master/examples/AndroidKotlin
from dsl-json.
Related Issues (20)
- About json field policy of object HOT 2
- Can't generate dsl for some kotlin data classes HOT 1
- Dependency org.postgresql:postgresql, leading to CVE problem HOT 1
- Question: Testing File Read with dsl-json HOT 2
- serialize/deserialize Set as a List HOT 2
- Question - Is possible to use array format with discriminator in abstract classes HOT 2
- Stack overflow error caused by dsl-json serialization Map HOT 2
- Does DSL-JSON Scale? HOT 5
- Polimorphic adapters HOT 9
- @CompiledJson annotation does not bind byte[] to BinaryConverter in v2.0.0 HOT 2
- Failure to serialize the basic generic objects. HOT 4
- support for kotlin value classes HOT 5
- JsonValue syntax tree HOT 7
- Filed filtering? HOT 4
- Re-using reader/writer. Make reset method public HOT 3
- Support reader.next(Class) inside a converter HOT 3
- Is there any support for deserialiazing from already parsed data? HOT 2
- Runtime reflection doesn't handle primitive boolean variables correctly HOT 4
- Configure for external classes using configuration HOT 1
- bug in `writerBinary` method of class `JsonWriter` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsl-json.