bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

com.bluelinelabs.logansquare.NoSuchMapperException #224

Closed posix-dev closed 6 years ago

posix-dev commented 6 years ago

Hello everyone!

I have such an error:

com.bluelinelabs.logansquare.NoSuchMapperException: could not be mapped to a JSON object. Perhaps it hasn't been annotated with @JsonObject?

My models:

@JsonObject
public class ProfileInfoData {

    // @JsonField(name = "accounts")

    // @JsonField(name = "raw_accounts")

    @JsonField(name = "chain_id")
    public ChainIdData chainIdData;

    @JsonField(name = "championat")
    public ChampionatData championatData;

    @JsonField(name = "contacts")
    public List<ContactsData> contactsList;

    @JsonField(name = "ctime")
    public long creationTime; // creation date as string or as  integer secs since epoch

    @JsonField(name = "email")
    public String email;

    @JsonField(name = "emails")
    public EmailsData emailsList;

    @JsonField(name = "phones")
    public List<String> phonesList;

    @JsonField(name = "rambler_mail_phone")
    public String ramblerMailPhone;

    @JsonField(name = "session")
    public SessionData sessionData;

    @JsonField(name = "social_profiles")
    public List<SocialProfilesData> socialProfilesList;
}
@JsonObject
class ChampionatData {
    @JsonField(name = arrayOf("all"))
    lateinit var championatData: Set<ChampionatDetailData>

    @JsonField(name = arrayOf("default"))
    lateinit var defaultInfo: DefaultChampionatData

    @JsonObject
    companion object DefaultChampionatData {
        @JsonField(name = arrayOf("account_id"))
        lateinit var defaultAccountId: String

        @JsonField(name = arrayOf("provider"))
        lateinit var defaultProvider: String
    }
}

And etc. Well, I looked at all the files and found no mistakes. I have not dropped the other files, since I do not want to litter the issue.

My build.gradle:

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

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.neenbedankt.android-apt'
apply from: 'publish_artifactory.gradle'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
        versionCode versionCode
        versionName version
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        disable 'Registered'
        lintConfig file("lint.xml")
    }
}

dependencies {
    ext.support_version = '25.3.1'

    apt 'com.bluelinelabs:logansquare-compiler:1.3.7'
    compile 'com.bluelinelabs:logansquare:1.3.7'
    compile "com.android.support:support-annotations:$ext.support_version"
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
    compile "com.android.support:customtabs:$ext.support_version"

    provided "com.android.support:support-v4:$ext.support_version"
    provided 'com.google.code.findbugs:jsr305:3.0.1' // we need this for annotations only

    testCompile "org.assertj:assertj-core:1.7.0"
    testCompile 'junit:junit:4.12'
    testCompile "org.robolectric:robolectric:3.1.2"
    testCompile 'com.squareup.okhttp3:mockwebserver:3.4.1'
    testCompile "org.mockito:mockito-core:1.10.19"
    testCompile 'com.squareup.okhttp3:okhttp:3.2.0'
    testCompile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

/*
this task was created to avoid bug in gradle/robolectric: robolectric(if runned from Android Studio)
tries firstly to get resources from build/intermediates/res but this directory doesn't contain any resources,
if we delete it, it will try to get resources from build/intermediates/bundles that's exactly what is needed
 */
task deleteIntermediatesResDir(type: Delete) {
    delete "build/intermediates/res"
}
repositories {
    mavenCentral()
    jcenter()
    google()
}

I hope, that I attached all necessary files into this issue. Thank you for answers in advance!!!

posix-dev commented 6 years ago

I'm sorry.

It was my mistake because I didn't prescribe kapt in build.gradle as I use kotlin.

I hope this mistake helps someone.