0

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'
}
John Ericksen
  • 10,995
  • 4
  • 45
  • 75
flower_green
  • 1,314
  • 2
  • 25
  • 30
  • Have you tried adding the following to your build.gradle : # Parcel library -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keep class org.parceler.Parceler$$Parcels – Smashing Aug 26 '15 at 10:00
  • Yes, it was on the library documentation. Indeed it surprised me to see those errors after the author took care of the proguard configuration too. – flower_green Aug 26 '15 at 10:04
  • FilerResourceWriter is only used during compile time annotation processing... are you using the android-apt plugin and apt scope for the Parceler processor in your build script? – John Ericksen Aug 30 '15 at 19:24
  • I'm not using them. I had to check because I didn't even know what they were, and so I didn't know if I could be using them without knowing. – flower_green Aug 31 '15 at 07:52
  • Ah, ok... Parceler should be either apt or provided scoped. Could you share your current build so I can make sure this is the issue? – John Ericksen Aug 31 '15 at 20:10
  • Here: http://pastebin.com/KDUPAjy9 I had to edit out some sensible information. What do you mean when you say that parceler should be apt or provided scoped? I never heard of those terms, if you have some tutorial or example at hand I would be thankful. – flower_green Aug 31 '15 at 20:57

1 Answers1

1

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"
}
John Ericksen
  • 10,995
  • 4
  • 45
  • 75