0

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
Prashant
  • 3,823
  • 3
  • 25
  • 40
  • Replace `implementation "org.parceler:parceler-api:$rootProject.ext.parcelVersion"` with `api "org.parceler:parceler-api:$rootProject.ext.parcelVersion"`. – CommonsWare Jul 27 '19 at 22:38
  • @CommonsWare I tried that, I am getting the same exception. – Prashant Jul 27 '19 at 22:44
  • You might need to also put `annotationProcessor "org.parceler:parceler:$rootProject.ext.parcelVersion"` in both `build.gradle` files. `api` allows your runtime library to be a transitive dependency, but I'm not sure how to make an annotation processor be a transitive dependency. – CommonsWare Jul 28 '19 at 11:04
  • @CommonsWare doing that solves the problem while debugging but if I try to make project or create APK it gives me the error 'Program type already present: org.parceler.Parceler$$Parcels$1' – Prashant Jul 28 '19 at 11:08

1 Answers1

1

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

Prashant
  • 3,823
  • 3
  • 25
  • 40