I am trying to build a release version of my application using proguard so that I can shrink resources and obfuscate my code. I am facing some referenced and library classes issues which gradle cannot find at runtime therefore giving some warnings as I mentioned below.
Gradle Console Warnings
I am facing these warnings when compiled to prepare release build using proguard
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find superclass or interface java.awt.Shape
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find superclass or interface java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator: can't find superclass or interface java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator$1: can't find superclass or interface java.awt.geom.PathIterator
Warning:library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser
Warning:com.google.firebase.messaging.FirebaseMessaging: can't find referenced method 'void zziy(java.lang.String)' in program class com.google.firebase.iid.FirebaseInstanceId
Warning:com.google.firebase.messaging.FirebaseMessaging: can't find referenced method 'java.lang.String zzaX(android.content.Context)' in program class com.google.firebase.iid.zzf
Warning:com.google.firebase.messaging.FirebaseMessagingService: can't find referenced method 'android.content.Intent zzUr()' in program class com.google.firebase.iid.FirebaseInstanceIdInternalReceiver
Warning:com.google.firebase.messaging.FirebaseMessagingService: can't find referenced method 'int zzA(android.content.Intent)' in program class com.google.firebase.iid.zzb
Warning:com.google.firebase.messaging.FirebaseMessagingService: can't find referenced method 'void zzBL()' in program class com.google.firebase.messaging.FirebaseMessagingService
Warning:com.google.firebase.messaging.zzb: can't find referenced method 'void zza(java.lang.String,java.lang.String,java.lang.Object)' in program class com.google.android.gms.measurement.AppMeasurement
Warning:com.google.firebase.messaging.zzc: can't find referenced method 'int zzap(android.os.Parcel)' in program class com.google.android.gms.common.internal.safeparcel.zza
Warning:com.google.firebase.messaging.zzc: can't find referenced method 'int zzaq(android.os.Parcel)' in program class com.google.android.gms.common.internal.safeparcel.zza
Warning:com.google.firebase.messaging.zzc: can't find referenced method 'int zzcj(int)' in program class com.google.android.gms.common.internal.safeparcel.zza
Warning:com.google.firebase.messaging.zzc: can't find referenced method 'void zzJ(android.os.Parcel,int)' in program class com.google.android.gms.common.internal.safeparcel.zzb
Warning:com.google.firebase.messaging.zzc: can't find referenced method 'int zzar(android.os.Parcel)' in program class com.google.android.gms.common.internal.safeparcel.zzb
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.Font
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.font.FontRenderContext
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.Font
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.font.GlyphVector
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.Font
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.font.FontRenderContext
Warning:com.vividsolutions.jts.awt.FontGlyphReader: can't find referenced class java.awt.font.GlyphVector
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.Rectangle
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.GeometryCollectionShape: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.IdentityPointTransformation: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$BasePointShapeFactory: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$BasePointShapeFactory: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Ellipse2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Ellipse2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Ellipse2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Ellipse2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Circle: can't find referenced class java.awt.geom.Ellipse2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Cross: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Cross: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Cross: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Cross: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Cross: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Cross: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Line2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Line2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Line2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Point: can't find referenced class java.awt.geom.Line2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Rectangle2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Rectangle2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Rectangle2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Square: can't find referenced class java.awt.geom.Rectangle2D$Double
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Star: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$Triangle: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PointShapeFactory$X: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PointTransformation: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.Rectangle
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.Rectangle2D
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.PolygonShape: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.ShapeCollectionPathIterator$1: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.geom.AffineTransform
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeReader: can't find referenced class java.awt.geom.PathIterator
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.Point2D$Double
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.Point2D
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.GeneralPath
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.Shape
Warning:com.vividsolutions.jts.awt.ShapeWriter: can't find referenced class java.awt.geom.Point2D
Warning:okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class java.nio.file.Files
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:library class android.content.Intent depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlSerializer
Warning:library class android.content.IntentFilter depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.content.res.ColorStateList depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.AnimatedVectorDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.AnimationDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.BitmapDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.ClipDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.ColorDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.Drawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.DrawableWrapper depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.GradientDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.InsetDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.LayerDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.RippleDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.ScaleDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.ShapeDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.StateListDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.graphics.drawable.VectorDrawable depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.util.Xml depends on program class org.xmlpull.v1.XmlSerializer
Warning:library class android.util.Xml depends on program class org.xmlpull.v1.XmlPullParser
Warning:library class android.view.LayoutInflater depends on program class org.xmlpull.v1.XmlPullParser
proguard-rules.pro
I tried a lot to get rid of these warnings but didn't find any effective solution. My proguard rules defined as below:
-printconfiguration config.txt
#-keep class * extends android.app.Activity
#-keep class * extends android.support.v4.app.Fragment
#-keep class * extends Application
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
public static *** e(...);
}
-keepattributes Signature
-keepattributes InnerClasses
#-keepattributes *Annotation*
-dontnote org.xmlpull.v1.**
-dontnote org.apache.http.**
-dontnote android.net.http.**
-keepclasseswithmembers,includedescriptorclasses class * { *; }
#-keep class com.vividsolutions.jts.awt.** { *; }
#-keep class android.content.XMLResourceParser { *; }
#-keep class com.google.firebase.messaging.** { *; }
#-keep class okio.** { *; }
#-keep class retrofit2.** { *; }
-keep class java.awt.** { *; }
-keep class com.google.firebase.iid.** { *; }
-keep class com.google.firebase.messaging.FirebaseMessagingService { *; }
-keep class com.google.android.gms.measurement.AppMeasurement { *; }
-keep class com.google.android.gms.common.internal.safeparcel.** { *; }
-keep class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement { *; }
-keep class java.nio.file.**
-keep class java.lang.invoke.**
-keep class org.xmlpull.v1.XmlPullParser { *; }
build.gradle [app]
packagingOptions {
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
The errors you are getting are because of missing classes that are not present in the set of input classes to ProGuard.
Example: the jts library uses AWT classes that are not present in Android.
Instead of using -keep
rules (which instruct ProGuard to keep existing classes from being obfuscated/shrunk/optimized), you will need to use -dontwarn
rules.
In the case of the jts library: -dontwarn java.awt.**
will hide the warnings wrt the AWT classes
You can also quickly test if all the warnings can be ignored by using -ignorewarnings
and build your application. If everything works afterwards it should be fine.