krschultz / android-proguard-snippets

Proguard configurations for common Android libraries
http://www.kevinrschultz.com/blog/2014/02/15/proguard-with-gradle/
Apache License 2.0
4.59k stars 598 forks source link

unknown reference to sun.misc.Unsafe in play-services #116

Open Palatis opened 8 years ago

Palatis commented 8 years ago

first apologize that I'm lazy to make a pull request...

api23+ is building with OpenJDK instead of Oracle JDK, which doesn't have sun.misc.Unsafe.

adding

-dontwarn com.google.common.cache.**
-dontwarn com.google.common.primitives.UnsignedBytes$**

to proguard-google-play-services.pro fixes warning:

Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1: can't find referenced class sun.misc.Unsafe

which renderes "Generate signed APK" to fail.

I dunno what side-effects would this introduce, tho.

90Sachin commented 8 years ago

Use this -keep class com.google. -dontwarn com.google.

krishnameena commented 8 years ago

Thanks. you saved my day.

LouisCAD commented 7 years ago

No need to prevent proguarding of all Protobuf. Just remove the warning for the referenced class with this in your proguard rules: -dontwarn sun.misc.Unsafe This will help make your apk smaller while ditching the warnings