Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.bluelinelabs.logansquare.NoSuchMapperException: Class in.manasviniganesh.ostracon.ostracon.Message could not be mapped to a JSON object. Perhaps it hasn't been annotated with @JsonObject? #209

Open
ManasviniGanesh opened this issue May 5, 2017 · 7 comments

Comments

@ManasviniGanesh
Copy link

## This error has been bothering me since days. LoganSquare's dependencies were installed along with Salut WiFi Library. I am using Salut and LoganSquare.

com.bluelinelabs.logansquare.NoSuchMapperException: Class in.manasviniganesh.ostracon.ostracon.Message could not be mapped to a JSON object. Perhaps it hasn't been annotated with @JsonObject?
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.bluelinelabs.logansquare.LoganSquare.mapperFor(LoganSquare.java:304)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.bluelinelabs.logansquare.LoganSquare.serialize(LoganSquare.java:149)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.peak.salut.BackgroundDataSendJob.doOnBackground(BackgroundDataSendJob.java:45)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.arasthel.asyncjob.AsyncJob$2.run(AsyncJob.java:59)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at java.lang.Thread.run(Thread.java:818)

# My gradle file

com.bluelinelabs.logansquare.NoSuchMapperException: Class in.manasviniganesh.ostracon.ostracon.Message could not be mapped to a JSON object. Perhaps it hasn't been annotated with @JsonObject?
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.bluelinelabs.logansquare.LoganSquare.mapperFor(LoganSquare.java:304)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.bluelinelabs.logansquare.LoganSquare.serialize(LoganSquare.java:149)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.peak.salut.BackgroundDataSendJob.doOnBackground(BackgroundDataSendJob.java:45)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at com.arasthel.asyncjob.AsyncJob$2.run(AsyncJob.java:59)
05-06 02:41:58.911 24358-26985/in.manasviniganesh.ostracon W/System.err:     at java.lang.Thread.run(Thread.java:818)
@mannodermaus
Copy link
Contributor

mannodermaus commented May 5, 2017

It seems like you've accidentally pasted the stack trace twice. Could you share your build.gradle & the Message class as well? From what I can from Salut's readme file, they don't seem to advertise the latest version of LoganSquare, so maybe your issue can already be resolved by simply upgrading to 1.3.7.

@Aawesh
Copy link

Aawesh commented Jun 2, 2017

Hi, did you find any solution to this ?

@VitorFontenelle
Copy link

VitorFontenelle commented Oct 26, 2017

I am using the same way as her (Salut), and I am getting the same error, so I think we may have a close build.gradle. For the record, I already tried using 1.3.6 and 1.3.7. If possible, show me what am I doing wrong:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.jotakape.interit.jokenpo"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.github.markrjr:Salut:v0.4.9'
    annotationProcessor 'com.github.markrjr:Salut:v0.4.9'
    compile 'com.bluelinelabs:logansquare:1.3.7'
    annotationProcessor 'com.bluelinelabs:logansquare:1.3.7'
    compile 'com.squareup:javapoet:1.2.0'
    annotationProcessor 'com.squareup:javapoet:1.2.0'
}

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

Also, here is my Message class:

@JsonObject
public class Message {

    /*
     * Annotate a field that you want sent with the @JsonField marker.
     */
    @JsonField
    public String description;
}

@mannodermaus
Copy link
Contributor

It's odd that your build.gradle file contains two independent dependencies blocks. I mean, it shouldn't theoretically be a problem, but can you merge their contents and try again? Also, do you see any generated code in your module's build/generated/source/apt folder?

@VitorFontenelle
Copy link

VitorFontenelle commented Oct 27, 2017

I merged them together and updated the previous comment, but the error was still the same.
My build/generated/source/apt folder only contains an empty "debug" folder.

@VitorFontenelle
Copy link

VitorFontenelle commented Oct 30, 2017

I actually got it working, it was kind of a dumb mistake, but... I only added theses two following lines in the dependencies and it started working:

    compile 'com.bluelinelabs:logansquare-compiler:1.3.7'
    annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.7'

I was caught by the Gradle trap. Found randomly in the internet that this wasn't enough:

    compile 'com.bluelinelabs:logansquare:1.3.7'
    annotationProcessor 'com.bluelinelabs:logansquare:1.3.7'

@mannodermaus
Copy link
Contributor

Oh wow, I didn't even spot that one either. Yes, there are two separate artifacts to LoganSquare, logansquare and logansquare-processor. Glad you found it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants