Search code examples
androidandroid-gradle-pluginbuild.gradleparcelparceler

Parceler class not generating error in Android


I have a core branch where following dependencies is decalared

implementation "org.parceler:parceler-api:$rootProject.ext.parcelVersion"
annotationProcessor "org.parceler:parceler:$rootProject.ext.parcelVersion"

I am declaring a dependency in one of my library module as below

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':core')
}

Here is the class that I will be parceling in my activity

@Parcel(parcelsIndex = false)
public class MyClass {
   @SerializedName("validation")
   public String myField;
}

Exception is thrown at the third line.

 MyClass myClass = new MyClass();
 myClass.myField = "bjbskas";
 Parcelable parcelable =Parcels.wrap(myClass);

Exception reads as shown below

Unable to find generated Parcelable class for com.example.mylibrary.MyClass, 
verify that your class is configured properly and that the Parcelable class 
com.example.mylibrary.MyClass$$Parcelable is generated by Parceler.

If I try putting the parceler library in my library module directly, it gives me another error called

Program type already present: org.parceler.Parceler$$Parcels$1

Solution

  • Changing the version of Parceler library from 1.0.4 to 1.1.10 solved the problem. I don't know what is the reason behind this but I guess it may be because of some transitive dependencies using version 1.1.10