flower_green
flower_green

Reputation: 1404

Using android Parceler library with minifyEnabled

Whenever I try to minify my project that makes use of the parceler library, I cannot build a release apk because of a lot of warnings from proguard. For example:

Warning:org.parceler.transfuse.gen.FilerResourceWriter: can't find referenced class javax.tools.FileObject

I don't even make use of most of the libraries reported in this messages. What I'd like to know is if someone has encountered this problem and managed to solve it. I tried to use -dontwarn to suppress all messages, but it does not seems correct, and besides it makes my app crash in rare cases (which makes me thing that some of the warning messages are indeed correct, but I'd like the library to keep the needed classes automatically).

My gradle script is as follows:

apply plugin: 'com.android.application'

...

dependencies {
    ...
    compile 'org.parceler:parceler:1.0.3'
}

Upvotes: 0

Views: 1417

Answers (1)

John Ericksen
John Ericksen

Reputation: 11113

You are seeing this error from Proguard because you've included Parceler as a runtime dependency. Parceler was designed to be included into your project as two separate libraries; the annotation processor and the api. If you're running Gradle your build script should look like the following:

compile "org.parceler:parceler-api:1.0.3"
apt "org.parceler:parceler:1.0.3"

See Getting Parceler.

where apt is the android-apt plugin. Secondarily, it can also be run under the provided scope.

Your build script will look like the following in the end:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        // replace with the current version of the Android plugin
        classpath 'com.android.tools.build:gradle:1.3.0'
        // the latest version of the android-apt plugin
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

...

dependencies {
    ...
    compile "org.parceler:parceler-api:1.0.3"
    apt "org.parceler:parceler:1.0.3"
}

Upvotes: 1

Related Questions