Guava: Update wiki regarding Proguard rules

Created on 7 May 2018  路  3Comments  路  Source: google/guava

Current rules in wiki is outdated, I getting massive amount of errors with guava:25.0-android.

https://github.com/google/guava/wiki/UsingProGuardWithGuava

Even better to include Proguard rules in library.

Currently I've got some usable configuration for my Android project.
Not sure that all of it is correct.

`-keep class com.google.common.io.Resources {
public static ;
}
-keep class com.google.common.collect.Lists {
public static * reverse(*);
}
-keep class com.google.common.base.Charsets {
public static ;
}

-keep class com.google.common.base.Joiner {
public static com.google.common.base.Joiner on(java.lang.String);
public ** join(...);
}

-keep class com.google.common.collect.MapMakerInternalMap$ReferenceEntry
-keep class com.google.common.cache.LocalCache$ReferenceEntry

-dontwarn javax.annotation.*
-dontwarn javax.inject.
*
-dontwarn sun.misc.Unsafe

-dontwarn java.lang.ClassValue
-dontwarn com.google.j2objc.annotations.Weak
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontwarn afu.org.checkerframework.*
-dontwarn org.checkerframework.
*
-dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue
-dontwarn com.google.errorprone.annotations.concurrent.LazyInit
-dontwarn com.google.errorprone.annotations.ForOverride
-dontwarn com.google.common.collect.MinMaxPriorityQueue
-dontwarn com.google.common.util.concurrent.FuturesGetChecked**
-dontwarn javax.lang.model.element.Modifier`

P3 status=triaged type=documentation

Most helpful comment

There was just a talk at Google I/O last week that included Proguard rules for the latest Guava. See https://stackoverflow.com/a/50338429/287575.

I agree, the documentation should be updated, and it would be ideal if these rules could be included in consumerProguardFiles in a future release.

All 3 comments

There was just a talk at Google I/O last week that included Proguard rules for the latest Guava. See https://stackoverflow.com/a/50338429/287575.

I agree, the documentation should be updated, and it would be ideal if these rules could be included in consumerProguardFiles in a future release.

These two rules were producing the error "Expecting java type before ';'". I changed them to match the existing rules for guava and those worked.

It turns out that Markdown was eating the type. The angle brackets needed to be quoted.

-keep class com.google.common.io.Resources {
# public static ; ### Expecting java type before ';'
public static \ }

-keep class com.google.common.base.Charsets {
# public static ; ### Expecting java type before ';'
public static \ }

Wiki was updated as part of the last revision on Jan 7th 2019:

Update Proguard configuration. Fixes https://github.com/google/guava/issues/3137

Was this page helpful?
0 / 5 - 0 ratings