Last active
April 19, 2016 11:56
-
-
Save orip/6807041 to your computer and use it in GitHub Desktop.
ProGuard rules for using Dagger 1.1.0 with gradle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
def dagger_version = "1.1.0" | |
compile "com.squareup.dagger:dagger:${dagger_version}" | |
compile "com.squareup.dagger:dagger-compiler:${dagger_version}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/a/18177491/37020 | |
# https://plus.google.com/114746422988923214718/posts/fhFucCgy8gr | |
-keepattributes *Annotation* | |
-keepclassmembers,allowobfuscation class * { | |
@javax.inject.* *; | |
@dagger.* *; | |
<init>(); | |
} | |
-keep class **$$ModuleAdapter | |
-keep class **$$InjectAdapter | |
-keep class **$$StaticInjection | |
-keepnames !abstract class com.example.mypackage.** | |
-keepnames class dagger.Lazy | |
# Gradle includes dagger-compiler and javawriter in the final package | |
-dontwarn dagger.internal.codegen.** | |
-dontwarn com.squareup.javawriter.** |
Just tried with dagger 1.2, does not work. Still getting a lot of proguard errors.
This is insufficient for Dagger 1.2 as module reflective fall-back was disabled, and the string-keys that Dagger uses are not obfuscatable. It should work for mere unused-code-stripping, but not for obfuscation.
Side note - you should do "-keepattributes Signature" as well if you have any generics.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this work? I'm still getting errors in the release apk. Even when using keep names for my package.