johncarl81 / parceler

:package: Android Parcelables made easy through code generation.
http://parceler.org
Apache License 2.0
3.56k stars 273 forks source link

Unable to find generated Parcelable class #261

Closed igormatos closed 6 years ago

igormatos commented 7 years ago

I've searched a lot on others issues, but haven't found a solution that works in my case. The class isn't being generated, I have debugged the Parcels.java

My model only has public properties, doesn't extend any class and has been annotated with @Parcel, some properties just have been annotated with @SerializedName from GSON.

Probably I am missing something... thanks in advance.

My build.gradle dependencies are

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'let'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'

repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'

[...]
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

project.ext {
    playServicesVersion = '2.2'
    supportPackageVersion = '23.2.1'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'

    //    UI
    compile 'com.xwray:passwordview:0.1'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'

    compile('com.github.jd-alexander:library:1.1.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile 'com.google.android.gms:play-services-location:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'
    compile 'com.google.android.gms:play-services-places:9.8.0'
    compile 'com.cocoahero.android:geojson:1.0.1@jar'

    compile 'com.google.firebase:firebase-database:9.8.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.5'
    compile 'io.realm:android-adapters:1.2.1'

    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }

    compile 'org.parceler:parceler-api:1.1.6'
    annotationProcessor 'org.parceler:parceler:1.1.6'

}
apply plugin: 'com.google.gms.google-services'
johncarl81 commented 7 years ago

Hmm, your build looks to be in order, can you share an example project to help diagnose?

grandstaish commented 7 years ago

I'd guess you're using an old Realm version. Pretty sure it bundled the android-apt plugin, making it incompatible with the new annotationProcessor scope. Try updating realm

igormatos commented 7 years ago

@grandstaish I have updated Realm to classpath "io.realm:realm-gradle-plugin:2.3.0" (the last one), now the error is being with the Data Binding that isn't being generated. If I use the apt command instead of annotationProcessor it doesn't recognize the command.

johncarl81 commented 7 years ago

FYI, using the apt scope requires the android-apt plugin.

igormatos commented 7 years ago

@johncarl81 hmm, still giving the same Data Binding error.

igormatos commented 7 years ago

Project Build.Gradle

    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }

    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath "io.realm:realm-gradle-plugin:2.3.0"
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'com.canelmas.let:let-plugin:0.1.11'
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App build.gradle

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'realm-android'
apply plugin: 'let'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'

repositories {
    maven {
        url 'https://maven.fabric.io/public'
    }
}
[...]
 buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

project.ext {
    playServicesVersion = '2.2'
    supportPackageVersion = '23.2.1'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'

    //    UI
    compile 'com.xwray:passwordview:0.1'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.yqritc:recyclerview-flexibledivider:1.4.0'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'

//    Location
    compile('com.github.jd-alexander:library:1.1.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile 'com.google.android.gms:play-services-location:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'
    compile 'com.google.android.gms:play-services-places:9.8.0'
    compile 'com.cocoahero.android:geojson:1.0.1@jar'

//    Realm and API
    compile 'com.google.firebase:firebase-database:9.8.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.5'
    compile 'io.realm:android-adapters:1.2.1'

    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }

    compile 'org.parceler:parceler-api:1.1.6'
    apt 'org.parceler:parceler:1.1.6'

}
apply plugin: 'com.google.gms.google-services'

Being Java 8 I need to use annotationProcessor right?

johncarl81 commented 7 years ago

What exactly is your data binding error?

igormatos commented 7 years ago

@johncarl81 My binding classes aren't being generated for some reason.

johncarl81 commented 7 years ago

Are they generated if you remove the parceler dependency?

igormatos commented 7 years ago

Yes, they are generated. The problem is when I annotate the model class with @Parceler. Just to note: this class doesn't extends RealmObject.

igormatos commented 7 years ago

I can not reproduce it, the sample app is configured the same way (Java 8, Realm and DataBinding) and is generating Data Binding and the Parceler class. I noticed that my app is generating the DataBinding, but it does not generate the Model $ Parcelable class. It shows me this error:

screenshot 2017-01-20 18 28 17

sample.zip* *tried with android-apt and annotationProcessor

johncarl81 commented 7 years ago

First impression, I notice you have not included the prescribed Parceler proguard rules: http://parceler.org/#configuring_proguard.

I'm not able to execute your build. Can you put together a more complete project?

igormatos commented 7 years ago

@johncarl81 But Proguard isn't enabled yet.

johncarl81 commented 7 years ago

ah, you may be right...

can you put together a project that is more complete that I can build from the command line?

igormatos commented 7 years ago

@johncarl81 you have to set your JAVA_HOME to use jdk 1.8 to build this project. Because I had to add Retrolambda to replicate my real context.