Proguard exception

3.1k Views Asked by At

I want to obfuscate my app so i've uncommented the proguard line in the project.properties file.

When i export the app in Eclipse i get the following error below.

It seems it cannot reference classes, some of which are from the Joda jar file. I have the Joda .jar file in my libs folder. i've tried putting it on the build path also but it still throws the same errors.

does anyone no what i'm doing wrong or how i should configure Proguard to skip files if necessary?

Thanks in advance.

[Update] I've managed to remove most of the Joda warnings by adding the Joda-convert jar to the build path

Android - Proguard didn't compile with Joda Time jar file

[2014-11-12 11:11:55 - nfcscanner] Proguard returned with error code 1. See console
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.analytics.GoogleAnalytics$b: can't find superclass or interface android.app.Application$ActivityLifecycleCallbacks
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.common.images.ImageManager$e: can't find superclass or interface android.content.ComponentCallbacks2
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find superclass or interface android.view.View$OnAttachStateChangeListener
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb$1: can't find superclass or interface android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.analytics.GoogleAnalytics: can't find referenced class android.app.Application$ActivityLifecycleCallbacks
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.analytics.GoogleAnalytics: can't find referenced method 'void registerActivityLifecycleCallbacks(android.app.Application$ActivityLifecycleCallbacks)' in class android.app.Application
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.analytics.GoogleAnalytics$b: can't find referenced class android.app.Application$ActivityLifecycleCallbacks
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.cast.TextTrackStyle: can't find referenced class android.view.accessibility.CaptioningManager$CaptionStyle
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced field 'int smallestScreenWidthDp' in class android.content.res.Configuration
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.common.images.ImageManager: can't find referenced method 'void registerComponentCallbacks(android.content.ComponentCallbacks)' in class android.content.Context
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.common.images.ImageManager$e: can't find referenced class android.content.ComponentCallbacks2
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'android.app.Fragment getParentFragment()' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'boolean getUserVisibleHint()' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'boolean isDetached()' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'void setMenuVisibility(boolean)' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.dynamic.b: can't find referenced method 'void setUserVisibleHint(boolean)' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced class android.view.View$OnAttachStateChangeListener
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'void addOnAttachStateChangeListener(android.view.View$OnAttachStateChangeListener)' in class android.view.View
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'void removeOnAttachStateChangeListener(android.view.View$OnAttachStateChangeListener)' in class android.view.View
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1: can't find referenced method 'void removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener)' in class android.view.ViewTreeObserver
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.internal.ed: can't find referenced method 'boolean isActiveNetworkMetered()' in class android.net.ConnectivityManager
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.internal.es: can't find referenced method 'java.lang.String getDefaultUserAgent(android.content.Context)' in class android.webkit.WebSettings
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.internal.es: can't find referenced method 'void setMediaPlaybackRequiresUserGesture(boolean)' in class android.webkit.WebSettings
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.internal.v: can't find referenced method 'void registerComponentCallbacks(android.content.ComponentCallbacks)' in class android.content.Context
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.internal.v: can't find referenced method 'void unregisterComponentCallbacks(android.content.ComponentCallbacks)' in class android.content.Context
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.maps.MapFragment: can't find referenced method 'void onInflate(android.app.Activity,android.util.AttributeSet,android.os.Bundle)' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.maps.StreetViewPanoramaFragment: can't find referenced method 'void onInflate(android.app.Activity,android.util.AttributeSet,android.os.Bundle)' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb$1: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb$1: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.tagmanager.bb$1: can't find referenced class android.util.LruCache
[2014-11-12 11:11:55 - nfcscanner] Warning: com.google.android.gms.wallet.fragment.WalletFragment: can't find referenced method 'void onInflate(android.app.Activity,android.util.AttributeSet,android.os.Bundle)' in class android.app.Fragment
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.DateMidnight: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.DateTime: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.DateTimeZone: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.DateTimeZone: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Days: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Days: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Duration: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Hours: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Hours: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Instant: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.LocalDate: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.LocalDate: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.LocalDateTime: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.LocalDateTime: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.LocalTime: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.LocalTime: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Minutes: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Minutes: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.MonthDay: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.MonthDay: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Months: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Months: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.MutableDateTime: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.MutableDateTime: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.MutablePeriod: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Period: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Seconds: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Seconds: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Weeks: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Weeks: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.YearMonth: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.YearMonth: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Years: can't find referenced class org.joda.convert.FromString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.Years: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.base.AbstractDuration: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.base.AbstractInstant: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner] Warning: org.joda.time.base.AbstractPeriod: can't find referenced class org.joda.convert.ToString
[2014-11-12 11:11:55 - nfcscanner]       You should check if you need to specify additional program jars.
[2014-11-12 11:11:55 - nfcscanner] Warning: there were 62 unresolved references to classes or interfaces.
[2014-11-12 11:11:55 - nfcscanner]          You may need to specify additional library jars (using '-libraryjars').
[2014-11-12 11:11:55 - nfcscanner] Warning: there were 20 unresolved references to program class members.
[2014-11-12 11:11:55 - nfcscanner]          Your input classes appear to be inconsistent.
[2014-11-12 11:11:55 - nfcscanner]          You may need to recompile them and try again.
[2014-11-12 11:11:55 - nfcscanner]          Alternatively, you may have to specify the option 
[2014-11-12 11:11:55 - nfcscanner]          '-dontskipnonpubliclibraryclassmembers'.
[2014-11-12 11:11:55 - nfcscanner] java.io.IOException: Please correct the above warnings first.
[2014-11-12 11:11:55 - nfcscanner]  at proguard.Initializer.execute(Initializer.java:321)
[2014-11-12 11:11:55 - nfcscanner]  at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-11-12 11:11:55 - nfcscanner]  at proguard.ProGuard.execute(ProGuard.java:86)
[2014-11-12 11:11:55 - nfcscanner]  at proguard.ProGuard.main(ProGuard.java:492)

project.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt

# Project target.
target=Google Inc.:Google APIs:11
android.library=false
android.library.reference.1=../google-play-services_lib

proguard-project.txt

# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}

-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}

-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}

-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
2

There are 2 best solutions below

0
On BEST ANSWER

[Solved]

I added the Joda jar to my build path. This still left 3 Joda warnings because i needed the Joda-convert jar on my build path also.

Don't download the Joda-convert1.7 jar as this will not work, you need the 1.4 version.

finally i added

-dontwarn com.google.android.gms.**

This removed the remaining gsm warnings.

It all works now.

0
On
-dontwarn com.google.**
-keep class com.google.** { *; }