Question

I am using external libraries like foursquare api and ABS library in my application.

When i enable proguard before exporting the app i get the below mentioned Error in console.

Proguard returned with error code 1. See console Note: there were 3686 duplicate class definitions. Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService Warning: fi.foyt.foursquare.api.io.GAEIOHandler: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletRequest Warning: fi.foyt.foursquare.example.AuthenticationExample: can't find referenced class javax.servlet.http.HttpServletResponse You should check if you need to specify additional program jars. Warning: there were 35 unresolved references to classes or interfaces. You may need to specify additional library jars (using '-libraryjars'). java.io.IOException: Please correct the above warnings first. at proguard.Initializer.execute(Initializer.java:321) at proguard.ProGuard.initialize(ProGuard.java:211) at proguard.ProGuard.execute(ProGuard.java:86) at proguard.ProGuard.main(ProGuard.java:492)

I understood that i have to mention the external libraries in Proguard properties file. How i should mention is the problem.

Please see my proguard file

-injars      bin/classes
-outjars     bin/classes-processed.jar
-libraryjars E:/android/adt-bundle-windows-x86_64-20131030/sdk/platforms/android-19/android.jar

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends android.app.Activity

-keep public class * extends android.app.Service

-keep public class * extends android.content.BroadcastReceiver


-keep public class * extends android.content.ContentProvider

-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
Was it helpful?

Solution

If you're exporting your Android application with the Android plugin, the plugin already specifies a standard configuration for you. This configuration includes the basic -keep options and all the necessary -injars and -outjars options (hence the note about duplicate class definitions). This means that your proguard-project.txt file can be empty to begin with; it should only contain any project-specific configuration.

The warnings explain that the Foursquare library refers to the AppEngine library and even to the servlet library, but these latter libraries are missing from your project. That's not a problem, since your app presumably works fine in debug mode, without these libraries, so you can tell ProGuard to ignore these issues:

-dontwarn fi.foyt.foursquare.**

See the ProGuard manual > Troubleshooting > Warning: can't find referenced class

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top