I try to use Proguard in my app. I wrote this code in proguard.cfg file:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class Mp4ParserWrapper.** { *; }
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
When export app get can't find referenced class error .I search on the internet and add this line -keep public class Mp4ParserWrapper. { *; }** to proguard file but don't solve problem .
Console :
[2015-10-16 17:29:09 - nabege] Proguard returned with error code 1. See console
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class javax.imageio.ImageIO
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class javax.imageio.ImageIO
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] Warning: com.googlecode.mp4parser.authoring.tracks.mjpeg.OneJpegPerIframe: can't find referenced class java.awt.image.BufferedImage
[2015-10-16 17:29:09 - nabege] You should check if you need to specify additional program jars.
[2015-10-16 17:29:09 - nabege] Warning: there were 6 unresolved references to classes or interfaces.
[2015-10-16 17:29:09 - nabege] You may need to specify additional library jars (using '-libraryjars').
[2015-10-16 17:29:09 - nabege] java.io.IOException: Please correct the above warnings first.
[2015-10-16 17:29:09 - nabege] at proguard.Initializer.execute(Initializer.java:321)
[2015-10-16 17:29:09 - nabege] at proguard.ProGuard.initialize(ProGuard.java:211)
[2015-10-16 17:29:09 - nabege] at proguard.ProGuard.execute(ProGuard.java:86)
[2015-10-16 17:29:09 - nabege] at proguard.ProGuard.main(ProGuard.java:492)
[2015-10-16 17:29:09 - nabege] Picked up _JAVA_OPTIONS: -Xms256m -Xmx512m
You need to add -dontwarn com.googlecode.mp4parser.**
Related
After upgrading to Google Play services v23, I see this message when trying to export signed application in Eclipse:
Proguard returned with error code 1. See console
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller$SessionInfo
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced class android.content.pm.PackageInstaller$SessionInfo
Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced method 'android.content.pm.PackageInstaller getPackageInstaller()' in class android.content.pm.PackageManager
Warning: com.google.android.gms.internal.zzif: can't find referenced method 'void setMixedContentMode(int)' in class android.webkit.WebSettings
You should check if you need to specify additional program jars.
Warning: there were 4 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Warning: there were 2 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
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 added this, as specified in documentation
-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;
}
and tried adding
-keep class android.content.pm.PackageInstaller.**
to proguard-project.txt, but this didnt help.
What am I missing?
hey i had the exact same error i fixed it by adding :
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
to my proguard.cfg
I have the same problem, but using Android Studio. Based on Lary Ciminera's solution, I added
-dontwarn com.google.android.gms.**
to proguard-project.txt.
I fixed it by adding this to proguard-project.txt:
-keep class android.content.pm.PackageInstaller
-keep class android.content.pm.PackageInstaller$SessionInfo
-keep class android.content.pm.PackageManager
-dontwarn android.content.pm.PackageInstaller
-dontwarn android.content.pm.PackageInstaller$SessionInfo
-dontwarn android.content.pm.PackageManager
-keep class android.webkit.WebSettings
-dontwarn android.webkit.WebSettings
Upgrading your target SDK version to at least 21 should fix this problem. PackageInstaller and the associated classes were added in API version 21: https://developer.android.com/reference/android/content/pm/PackageInstaller.html
I have parse 1.5.1 in my app and everything works fine, but when I go to export to APK I get:
[2014-09-05 19:53:08 - myapp] Proguard returned with error code 1. See console
[2014-09-05 19:53:08 - myapp] Note: there were 662 duplicate class definitions.
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider$1: can't find superclass or interface com.facebook.android.Facebook$ServiceListener
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider$2: can't find superclass or interface com.facebook.Session$StatusCallback
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider$2$1: can't find superclass or interface com.facebook.Request$Callback
[2014-09-05 19:53:08 - myapp] Warning: com.parse.FacebookAuthenticationProvider: can't find referenced class com.facebook.android.Facebook
......
[2014-09-05 19:53:08 - myapp] at proguard.Initializer.execute(Initializer.java:321)
[2014-09-05 19:53:08 - myapp] at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-09-05 19:53:08 - myapp] at proguard.ProGuard.execute(ProGuard.java:86)
[2014-09-05 19:53:08 - myapp] at proguard.ProGuard.main(ProGuard.java:492)
In my proguard.cfg I have the following:
-keepattributes *Annotation*
-keep class com.parse.* { *; }
-libraryjars libs/Parse-1.5.1.jar
This is driving me crazy!!!
You should try also keeping the subpackages of com.parse:
-keepattributes *Annotation*
-keep class com.parse.** { *; }
You should not add -libraryjars options, since the Android build process already automatically specifies all necessary -injars, -outjars, and -libraryjars for you. It only causes warnings about duplicate classes.
Mine was fixed by adding this:
-keep class com.parse.* { *; }
-dontwarn com.parse.**
Reference: this post.
I created project use LocationClient (in Google Play service)
But I have a problem when export release with groguard. I added proguard-config like here (http://developer.android.com/google/play-services/setup.html#Proguard)
But It still error when export. Can anybody help me show this problem.
[2014-04-28 08:10:14 - myProject] Proguard returned with error code 1. See console
[2014-04-28 08:10:14 - myProject] Note: there were 619 duplicate class definitions.
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.analytics.GoogleAnalytics$b: can't find superclass or interface android.app.Application$ActivityLifecycleCallbacks
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.common.images.ImageManager$e: can't find superclass or interface android.content.ComponentCallbacks2
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.analytics.GoogleAnalytics: can't find referenced class android.app.Application$ActivityLifecycleCallbacks
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.analytics.GoogleAnalytics: can't find referenced method 'void registerActivityLifecycleCallbacks(android.app.Application$ActivityLifecycleCallbacks)' in class android.app.Application
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.analytics.GoogleAnalytics$b: can't find referenced class android.app.Application$ActivityLifecycleCallbacks
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced field 'int smallestScreenWidthDp' in class android.content.res.Configuration
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.common.images.ImageManager: can't find referenced method 'void registerComponentCallbacks(android.content.ComponentCallbacks)' in class android.content.Context
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.common.images.ImageManager$e: can't find referenced class android.content.ComponentCallbacks2
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.common.images.a: can't find referenced method 'android.graphics.drawable.Drawable[] getCompoundDrawablesRelative()' in class android.widget.TextView
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.common.images.a: can't find referenced method 'void setCompoundDrawablesRelativeWithIntrinsicBounds(android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable,android.graphics.drawable.Drawable)' in class android.widget.TextView
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.internal.cx: can't find referenced method 'java.lang.String getDefaultUserAgent(android.content.Context)' in class android.webkit.WebSettings
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.internal.cx: can't find referenced method 'void setMediaPlaybackRequiresUserGesture(boolean)' in class android.webkit.WebSettings
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.internal.gd$b: can't find referenced method 'android.view.Display getDisplay()' in class android.view.View
[2014-04-28 08:10:14 - myProject] Warning: com.google.android.gms.internal.gd$b: can't find referenced method 'void removeOnGlobalLayoutListener(android.view.ViewTreeObserver$OnGlobalLayoutListener)' in class android.view.ViewTreeObserver
[2014-04-28 08:10:14 - myProject] You should check if you need to specify additional program jars.
[2014-04-28 08:10:14 - myProject] Warning: there were 5 unresolved references to classes or interfaces.
[2014-04-28 08:10:14 - myProject] You may need to specify additional library jars (using '-libraryjars').
[2014-04-28 08:10:14 - myProject] Warning: there were 9 unresolved references to program class members.
[2014-04-28 08:10:14 - myProject] Your input classes appear to be inconsistent.
[2014-04-28 08:10:14 - myProject] You may need to recompile them and try again.
[2014-04-28 08:10:14 - myProject] Alternatively, you may have to specify the option
[2014-04-28 08:10:14 - myProject] '-dontskipnonpubliclibraryclassmembers'.
[2014-04-28 08:10:14 - myProject] java.io.IOException: Please correct the above warnings first.
[2014-04-28 08:10:14 - myProject] at proguard.Initializer.execute(Initializer.java:321)
[2014-04-28 08:10:14 - myProject] at proguard.ProGuard.initialize(ProGuard.java:211)
[2014-04-28 08:10:14 - myProject] at proguard.ProGuard.execute(ProGuard.java:86)
[2014-04-28 08:10:14 - myProject] at proguard.ProGuard.main(ProGuard.java:492)
Thanks a million!
You should add the android specific configuration as well.
Copied from the link:
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-keepclassmembers class * {
#android.webkit.JavascriptInterface <methods>;
}
I am using the gmailsender to send email in my app. I followed the link below Sending Email in Android using JavaMail API without using the default/built-in app
I have however noticed that whenever I use proguard to build my APK, then the gmail sender does not work(when I install that APK). There is no error thrown, but emails are not sent. If I disable proguard and then generate the APK, then it works fine using that APK.
Can anyone please suggest what might be wrong here.
:::EDIT:::-ADDED FEW ERROR MESAGE(abridged) LINES FROM CONSOLE WHILE GENERATING APK. I COULD GET RID OF THOSE WARNING HOWEVER BY IGNORING THEM IN PROGUARD CONFIG FILE
[2013-07-09 10:00:38 - ] Proguard returned with error code 1. See console
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.auth.callback.NameCallback
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmCallback
[2013-07-09 10:00:38 - ] Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator$1: can't find referenced class javax.security.sasl.RealmChoiceCallback
[2013-07-09 10:00:38 - ] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2013-07-09 10:00:38 - ] Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.GraphicsEnvironment
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] Warning: org.apache.harmony.awt.ContextStorage: can't find referenced class java.awt.Toolkit
[2013-07-09 10:00:38 - ] You should check if you need to specify additional program jars.
[2013-07-09 10:00:38 - ] Warning: there were 247 unresolved references to classes or interfaces.
[2013-07-09 10:00:38 - ] You may need to specify additional library jars (using '-libraryjars').
[2013-07-09 10:00:38 - ] java.io.IOException: Please correct the above warnings first.
[2013-07-09 10:00:38 - ] at proguard.Initializer.execute(Initializer.java:321)
[2013-07-09 10:00:38 - ] at proguard.ProGuard.initialize(ProGuard.java:211)
[2013-07-09 10:00:38 - ] at proguard.ProGuard.execute(ProGuard.java:86)
[2013-07-09 10:00:38 - ] at proguard.ProGuard.main(ProGuard.java:49
Finally solved the problem by updating to latest version of proguard from 4.7 to 4.9.
also added the following to the proguard config file
-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}
Can any one help me which i am using ProGuard in my Android Application i am getting Following Error While i am Signed it to Export.
Here what my Console Show me.
[2011-11-03 16:07:52 - AndroidViewPager] Proguard returned with error code 1. See console
[2011-11-03 16:07:52 - AndroidViewPager] Note: there were 95 duplicate class definitions.
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find superclass or interface android.os.Parcelable$ClassLoaderCreator
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void invalidateOptionsMenu()' in class android.app.Activity
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])' in class android.app.Activity
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.os.ParcelableCompatCreatorHoneycombMR2: can't find referenced class android.os.Parcelable$ClassLoaderCreator
[2011-11-03 16:07:52 - AndroidViewPager] Warning: android.support.v4.view.MenuCompatHoneycomb: can't find referenced method 'void setShowAsAction(int)' in class android.view.MenuItem
[2011-11-03 16:07:52 - AndroidViewPager] Warning: there were 3 unresolved references to classes or interfaces.
[2011-11-03 16:07:52 - AndroidViewPager] You may need to specify additional library jars (using '-libraryjars'),
[2011-11-03 16:07:52 - AndroidViewPager] or perhaps the '-dontskipnonpubliclibraryclasses' option.
[2011-11-03 16:07:52 - AndroidViewPager] Warning: there were 3 unresolved references to program class members.
[2011-11-03 16:07:52 - AndroidViewPager] Your input classes appear to be inconsistent.
[2011-11-03 16:07:52 - AndroidViewPager] You may need to recompile them and try again.
[2011-11-03 16:07:52 - AndroidViewPager] Alternatively, you may have to specify the options
[2011-11-03 16:07:52 - AndroidViewPager] '-dontskipnonpubliclibraryclasses' and/or
[2011-11-03 16:07:52 - AndroidViewPager] '-dontskipnonpubliclibraryclassmembers'.
[2011-11-03 16:07:52 - AndroidViewPager] java.io.IOException: Please correct the above warnings first.
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.Initializer.execute(Initializer.java:308)
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.ProGuard.initialize(ProGuard.java:210)
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.ProGuard.execute(ProGuard.java:85)
[2011-11-03 16:07:52 - AndroidViewPager] at proguard.ProGuard.main(ProGuard.java:499)
I think in jar may be some thing not proper.
How to give specify additional library jars i am using following Proguard.cfg file
optimizationpasses 5
-dontpreverify
-verbose
-libraryjars 'E:\Himanshu\AndroidViewPager\libs\android-support-v4.jar'
-dontskipnonpubliclibraryclasses
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
Adding the following to proguard.cfg worked for me. I think its because you are not using honeycomb but the compatibility library has some honeycomb specific things in it.
-dontwarn CompatHoneycomb -keep class android.support.v4. { *; }
-dontwarn **CompatCreatorHoneycombMR2
-dontwarn **ActivityCompatHoneycomb
-dontwarn **MenuCompatHoneycomb
Also, remove
libraryjars 'E:\Himanshu\AndroidViewPager\libs\android-support-v4.jar'
I had the same issue. Turns out, I needed to update the project's build target.
Looks like the version of android-support-v4.jar needs to match the project build target version in order for proguard to work. In my case, android-support-v4.jar revision 10 needs to have build target Android 4.1.2 (API 16) set up in Package Explorer Project > Properties > Android.
In AndroidManifest.xml, I still have android:targetSdkVersion="13" set. This setting seems to have no connection to the problem.
method void setShowAsAction(int) is not available in compatibility library.
Try using menu's xml file parameters
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#[+][package:]id/resource_name"
android:title="string"
android:titleCondensed="string"
android:icon="#[package:]drawable/drawable_resource_name"
android:onClick="method name"
android:showAsAction=["ifRoom" | "never" | "withText" | "always" |
"collapseActionView"]
.../>
</menu>