Proguard issue when enabling it - android

Proguard returned with error code 1. See console
Warning: com.google.android.gms.ads.formats.NativeAdView: can't find referenced method 'FrameLayout(android.content.Context,android.util.AttributeSet,int,int)' in class android.widget.FrameLayout
You should check if you need to specify additional program jars.
Warning: there were 1 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 change the Project Build Target from Android 4.4.2 to Android 5.1.1 and then the problem does not happen again.
Hope it helps.

Related

How to find out which classes cannot be resolved by ProGuard Android

After adding ProGuard rules for all libraries I am using, I still get this warning:
Warning: there were 14 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
I know that I can probably use the -dontwarn option to get rid of this warning, but therefore I need to know which packages/classes/interfaces cannot be resolved. Android does not support a global "-dontwarn".
In the log file I find so many Notes and Warnings, but none of them seem to relate the above message.
If you receive a Warning: there were X unresolved references to classes or interfaces then look for lines in your build log that contain the word Warning, such as this:
Warning: com.package.Class1: can't find referenced class org.library.Class2
Lines like this will tell which classes ProGuard is trying to work on and which classes can't be found in the input jars. In the example above, class Class1 would reference Class2 of a library but Class2 was not found in the build path.
As you mentioned, you can simply add -dontwarn <class regex> to ignore those warnings but ideally you should check them one-by-one to make sure that your configuration is correct and all required dependencies are being imported correctly.

Warning with Proguard and EndlessAdapter. App crashes

Have errors on exporting android app and proguard. Without using proguard, app works ok. I have com.commonsware.cwac.endless.EndlessAdapter library as third party in my code, and proguard throws that error when exporting the project...
Proguard returned with error code 1. See console
Warning: com.commonsware.cwac.endless.EndlessAdapter: can't find referenced field 'java.util.concurrent.Executor THREAD_POOL_EXECUTOR' in class android.os.AsyncTask
Warning: com.commonsware.cwac.endless.EndlessAdapter: can't find referenced method 'android.os.AsyncTask executeOnExecutor(java.util.concurrent.Executor,java.lang.Object[])' in class android.os.AsyncTask
You should check if you need to specify additional program jars.
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)
Any idea? Something extra to put in my proguard-project.txt??? Thankssss
This field and this method are only available in android-11 or higher, so you should build against the target android-11 or higher. Can can still specify a different targetSdkVersion in your AndroidManifest.xml file.

Akward Proguard error on new (blank) project

After creating new android project I just put the name and package name... and nothing else
then in the project.properties I add
proguard.config=proguard-project.txt
then if I try to export signed apk I get this error
[2013-09-19 12:05:57 - ProguardTest] Warning: there were 12 unresolved
references to classes or interfaces. [2013-09-19 12:05:57 -
ProguardTest] You may need to specify additional library jars
(using '-libraryjars'). [2013-09-19 12:05:57 - ProguardTest] Warning:
there were 12 unresolved references to program class members.
[2013-09-19 12:05:57 - ProguardTest] Your input classes
appear to be inconsistent. [2013-09-19 12:05:57 - ProguardTest]
You may need to recompile them and try again. [2013-09-19 12:05:57 -
ProguardTest] Alternatively, you may have to specify the
option [2013-09-19 12:05:57 - ProguardTest]
'-dontskipnonpubliclibraryclassmembers'. [2013-09-19 12:05:57 -
ProguardTest] Error: Please correct the above warnings first.
This is the strange part if I untick "Android Private Libraries" on the Order and Export tab of the build path editor it just works fine
Depending on the details in the error log (before the quoted lines), you may need to add missing libraries, build against a more recent Android runtime, or just specify -ignorewarnings or -dontwarn.
See the ProGuard manual > Troubleshooting > Warning: can't find referenced class
See the ProGuard manual > Troubleshooting > Warning: can't find referenced field/method '...' in program class ...
Note that proguard.config in the file project.properties typically also points to a generic configuration file proguard-android.txt inside the Android SDK. The file proguard-project.txt then only needs to contain project-specific configuration.

Why is ProGuard suddenly unable to compile my application?

I've been using Android Studio since the initial release without any ProGuard issues. Suddenly today it has stopped working. As far as I know any files which would interfere with Proguard have not changed. For instance my ProGuard config file remains untouched, and ActionBarSherlock (one of the modules now experiencing errors) was not changed in any way since the last successful build.
The error log recommended using -dontskipnonpubliclibraryclassmembers however that does not resolve the issue. Running ProGuard with the included default configuration rather than my own still results in the same errors.
From what I can make of it, when Android Studio is building my app, the modules are now being stripped from the app. I'm not sure if it's just not passing the appropriate flags to ProGuard or if Proguard is removing them on its own.
Some relevant logs:
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.content.Context mContext' in class com.actionbarsherlock.widget.SuggestionsAdapter
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced method 'android.database.Cursor getCursor()' in class com.actionbarsherlock.widget.SuggestionsAdapter
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.database.Cursor mCursor' in class com.actionbarsherlock.widget.SuggestionsAdapter
--snip--
ProGuard: [Meditation Assistant] You should check if you need to specify additional program jars.
ProGuard: [Meditation Assistant] Warning: there were 10 unresolved references to classes or interfaces.
ProGuard: [Meditation Assistant] You may need to specify additional library jars (using '-libraryjars').
ProGuard: [Meditation Assistant] Warning: there were 191 unresolved references to program class members.
The message
Warning: there were 10 unresolved references to classes or interfaces.
suggests that ProGuard can't find some classes that are required. These classes are listed in ProGuard's earlier console output. You should check that all the necessary jars are in the directory 'libs'. In this case, android-support-v4.jar might be missing.
I solved it adding the following line to proguard-project.txt:
-libraryjars libs/android-support-v4.jar
In case of using Eclipse do not forget to clean the project before exporting the APK.

socialauth-android: proguard errors when exporting apk

Using socialauth-android, when I try to export my project I get these warnings:
Warning: org.brickred.socialauth.util.SocialAuthUtil: can't find referenced class javax.servlet.http.HttpServletRequest
Warning: there were 111 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
Warning: there were 140 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code or update the library versions.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:330)
at proguard.ProGuard.initialize(ProGuard.java:212)
at proguard.ProGuard.execute(ProGuard.java:87)
at proguard.ProGuard.main(ProGuard.java:484)
Could someone help?
Problem is gone using this proguard cfg:
-keep class org.brickred.** { *; } -dontwarn org.brickred.**
Do you have the jars directly in your libs? Or are you getting them through maven? Which sdk version are you running?
If you add jars in at compile time, it might not get included in proguard processing. The jars has to be in place after pre-build target is ran.

Categories

Resources