Using Parceler with Android

I am trying Parceler library for Android. So far, I have had only one error using a simple sample from the documentation.

@Parcel(Parcel.Serialization.BEAN) public class Example { private String name; private int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } 

and

 Parcelable p = Parcels.wrap(new Example()); 

Crash with

 07-30 12:31:46.439: E/AndroidRuntime(4945): FATAL EXCEPTION: main 07-30 12:31:46.439: E/AndroidRuntime(4945): Process: com.sample.app.android.debug, PID: 4945 07-30 12:31:46.439: E/AndroidRuntime(4945): org.parceler.ParcelerRuntimeException: Unable to find generated Parcelable class for com.sample.app.android.entity.Example, verify that your class is configured properly and that the Parcelable class com.sample.app.android.entity.Example$$Parcelable is generated by Parceler. 07-30 12:31:46.439: E/AndroidRuntime(4945): at org.parceler.Parcels$ParcelCodeRepository.get(Parcels.java:201) 07-30 12:31:46.439: E/AndroidRuntime(4945): at org.parceler.Parcels.wrap(Parcels.java:85) 07-30 12:31:46.439: E/AndroidRuntime(4945): at org.parceler.Parcels.wrap(Parcels.java:69) 

What am I missing?

+6
source share
3 answers

It appears that the annotation handler is not working or is configured incorrectly. I would recommend using the Processoror annotation area if you use the Gradle construct along with separate areas for processor libraries and api:

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

For more information, see Getting Parceler on the website.

+3
source

In the new version, you only need to update the following dependencies in the Gradle file:

 compile 'org.parceler:parceler-api:1.1.6' annotationProcessor 'org.parceler:parceler:1.1.6' 
+3
source

The error is related to the annotation. it works by implementing in build.gradle

 annotationProcessor 'org.parceler:parceler:1.1.9' 
0
source

All Articles