Giter VIP home page Giter VIP logo

Comments (8)

zapov avatar zapov commented on August 22, 2024

I'll try to replicate your setup. In the meantime I would try:

  1. using clean before the build
  2. 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.

dvhp avatar dvhp commented on August 22, 2024

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.

zapov avatar zapov commented on August 22, 2024

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.

zapov avatar zapov commented on August 22, 2024

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.

dvhp avatar dvhp commented on August 22, 2024

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.

dvhp avatar dvhp commented on August 22, 2024

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.

zapov avatar zapov commented on August 22, 2024

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.

zapov avatar zapov commented on August 22, 2024

I've added Android Kotlin example: https://github.com/ngs-doo/dsl-json/tree/master/examples/AndroidKotlin

from dsl-json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.