Search code examples
androidparceler

How to add compiler argument "-AparcelerStacktrace" to debug Parceler Android library


All is in the title ;)

I cannot get rid of this error at build time... I've checked how to add the "-AparcelerStacktrace" compiler argument for this library but didn't find it on its Github repo. I've also checked how to simply add a "generic" compiler argument but didn't find how too...

I'm a bit stuck with this error :/

For info, I'm using Parceler 1.0.1.

EDIT

Finally, the error message appeared because of a duplicate of a class with a @Parcel annotation... However, I let the post opened to know how to add a compiler argument in Android ;)


Solution

  • To add annotation processor arguments (-A...) you just need to configure the compiler.

    In Maven this is configured via the maven-compiler-plugin as follows:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
            <compilerArguments>
                <AparcelerStacktrace/>
            </compilerArguments>
        </configuration>
    </plugin>
    

    In gradle this is configured for Android as follows:

    android {
        ...
        defaultConfig {
            ...
            javaCompileOptions {
                annotationProcessorOptions {
                    arguments = [
                        parcelerStacktrace: "true"
                    ]
                }
            }
        }
    }