Android Build Failed: During release - android

I am unable to export signed apk file.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Please correct the above warnings first.
Warnings are follows:
Warning:there were 92 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)
Warning:there were 1 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED

You need to look carefully at the mentioned warnings in your build log and add appropriate -dontwarn xxx.yyy rules to your ProGuard configuration.
These warnings usually indicate that you have a problem in your configuration, e.g. referencing a class that is not present. This can because of Java libraries that have been developed for a standard Java SDK using classes / methods that are not present when developing an Android application.
To completely ignore these warnings and just let ProGuard process your application, you can also use the -ignorewarnings rule.

Related

Cant debug build app on android 4.4.2 but it works on android 6.0.1

The error I get is:(this is a large project)
Note: there were 10 references to unknown classes.
You should check your configuration for typos.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 239 unkept descriptor classes in kept class members.
You should consider explicitly keeping the mentioned classes
(using '-keep').
(http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 27 unresolved dynamic references to classes or interfaces.
You should check if you need to specify additional program jars.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: there were 2292 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)
Warning: there were 241 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForDebug FAILED
FAILURE: Build failed with an exception.
ThereĀ“s a big log output from Gradle and I know I must clean up the proguard-rules.pro eventually but why does it work on android 6.0.1 and not on android 4.4.2. The log end with "Build failed with an exception" and I try to "Run with --stacktrace " but cant see the exception
I solved it.
The reason was in app build gradle I was using play-services 11.4.0 and firebase 11.4.2.
Somehow I missed syncing them to use the same version..

Getting "unresolved references" and "can't find superclass" warnings from Proguard

I have integrated some third-party source into my android project and I'm having trouble getting it to build with proguard enabled. The build is failing with this:
Warning: there were 123 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)
Warning: there were 201 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED
FAILURE: Build failed with an exception.
There are MANY notes and warnings to sort through and I can't make heads or tails of it. I have tried adding --keep class example.package.** { *; } for everything that seems to be causing warnings, but it is still failing. Can anyone suggest a strategy for dealing with issues like this? For example, if I see this:
Warning: info.guardianproject.netcipher.client.MyDefaultClientConnectionOperator: can't find superclass or interface ch.boye.httpclientandroidlib.impl.conn.DefaultClientConnectionOperator
what should I do about it?
Adding the following to your proguard-file will solve the compile problem:
-dontwarn info.guardianproject.netcipher.**
That said, you should read up on any ramifications that would come with this. Proguard is usually giving warnings for a good reason.
The reason you get those warnings is that guardianproject messed up with dependencies. As you can see here NetCipher does not have any dependencies. And httpclientandroidlib is clearly an outern project. Inside Netcipher they have built the .jar library and not packaging it into their library. Unfortunately, httpclientandroidlib is not available through jcenter dependency.
There are two solutions:
Proposed by #Tommie: add
-dontwarn info.guardianproject.netcipher.**
to you proguard-rules.pro file if those dependecies are not necessary. You just get rid of warning, sometimes it is a good way. But usually does not work. Then go to step two
You need to add httpclientandroidlib manually to your project.
Download a project from github as .zip
Add new module to your project, name it httpclientandroidlib (name is arbitrary. I name it like that just for reference)
Copy folder structure ch.boye.httpclientandroidlib to new module's src folder
Replace module's AndroidManifest with the one from httpclientandroidlib library.
Add dependecy to your main aa module:
compile project(':httpclientandroidlib')
Then you can start working with the project.

Gradle issue - You may need to add missing library jars or update their versions

When I try to generate a release version for my app I get the bellow error :
Error:Execution failed for task ':app:proguardRelease'.
java.io.IOException: Please correct the above warnings first.
Blockquote
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)
How can I force Android Studio Gradle plugin to use -dontwarn option ?
This occurs because the release build is using Proguard. You will need to add Proguard rules in proguard-rules.pro for some of the dependencies you are using. Most libraries provide the Proguard rules needed; look on their README page.
The -dontwarn option isn't an option for Android Studio or the Android Gradle Plugin. It is a ProGuard option used to tell ProGuard not to warn you about potential problems.
From the ProGuard manual:
-dontwarn
Specifies not to warn about unresolved references and other important problems at all. The optional filter is a regular expression; ProGuard doesn't print warnings about classes with matching names. Ignoring warnings can be dangerous. For instance, if the unresolved classes or class members are indeed required for processing, the processed code will not function properly. Only use this option if you know what you're doing!
If you need to use this option, then it should go in your project-specific ProGuard file (see here if you don't know how to add your own ProGuard file).

Android Studio 0.5.0 rebuild not working with Proguard

Recently I updated Android Studio from 0.4.2 to 0.5.0 and Android Gradle Plug-In from 0.7.2 to 0.9.0 as the IDE suggested. The project runs and installs good but when I press Build->Rebuild Project it throws an error, which stops the rebuild.
Here is an error in Messages tab:
Information:See complete output in console
Error:Execution failed for task ':projectName:proguardDebug'.
> java.io.IOException: Please correct the above warnings first.
And here is the problem discribed in the console:
:projectName:proguardDebug
Note: there were 2345 duplicate class definitions.
Warning: com.facebook.Settings: can't find referenced class com.facebook.android.BuildConfig
Warning: com.facebook.Settings: can't find referenced class com.facebook.android.BuildConfig
Warning: com.facebook.internal.Utility: can't find referenced class com.facebook.android.BuildConfig
Warning: com.facebook.internal.Utility: can't find referenced class com.facebook.android.BuildConfig
Warning: there were 4 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)
:projectName:proguardDebug FAILED
FAILURE: Build failed with an exception.
As I understood, the problem is missing BuildConfig.java, which was in /gen folder before I migrated from Eclipse. But now there is not /gen folder and BuildConfig.java is in the /build/source/buildConfig/debug/ forlder.
I found the only sollution that really does something to this, it is adding the line
-dontwarn com.facebook.**
to the proguard config file, but it isn't really the sollution.
The problem is that our libraries don't package BuildConfig. This is because we allow (for now) libraries to have the same package name. we are going to change this.
This shouldn't be a problem as BuildConfig is only constants that should get inlined in the code anyway. You can do a temp fix with excluding only BuildConfig:
-dontwarn com.facebook.android.BuildConfig
We'll probably fix this soon.
From the link in the warning:
If the missing class is referenced from a pre-compiled third-party library, and your original code runs fine without it, then the missing dependency doesn't seem to hurt. The cleanest solution is to filter out the referencing class or classes from the input, with a filter like "-libraryjars mylibrary.jar(!somepackage/SomeUnusedReferencingClass.class)". ProGuard will then skip this class entirely in the input, and it will not bump into the problem of its missing reference. However, you may then have to filter out other classes that are in turn referencing the removed class. In practice, this works best if you can filter out entire unused packages at once, with a wildcard filter like "-libraryjars mylibrary.jar(!someunusedpackage/**)".
If you don't feel like filtering out the problematic classes, you can try your luck with the -ignorewarnings option, or even the -dontwarn option. Only use these options if you really know what you're doing though.

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