Set "minifyEnabled" to "false" for external libraries only - android

I have this error when I'm building the apk with an external library (SumUp)
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'.
> Job failed, see logs for details
Removing the library or setting "minifyEnabled" to "false" remove the error, but I don't want to do that.
How can I avoid shrinking only the external library?
I tried to modify the proguard file :
-keep class com.sumup.**
... with no success.

You should run your gradle build with the -i option to get more output and be able to solve your problem. Most likely ProGuard will output some warnings about the sumup library and fails to continue.
You can test this theory by adding -ignorewarnings to your proguard configuration file. It will probably succeeds, but you should take a look at the warnings as try to fix them.

Related

How to get the proguard rules of each dependency?

I have a project that depends on some maven lib, after proguard I got the files under package com.xxx kept, but I didn't add the rule in my project proguard files, I must be imported from maven lib. I know there will be a merged proguard file during progurad processure. My question is there a way to hook the processure and prints the separated proguard rules, or how to find which lib imports the rule.
Thanks in advance.
Modify your proguard-project.txt to include
-printconfiguration "build/outputs/mapping/configuration.txt"
Trigger proguard run with ./gradlew assembleRelease and inspect the file. It doesn't always tell which aar or jar has contributed it though. Maybe create feature request for AGP to make behaviour consistent with aapt which prints where every line is coming from.

Android Proguard -android is not supported?

I add '-android' in my project's proguard-rules.pro file,but when I release my project,the Gradle Console gives the Warning:
Warning: Exception while processing task java.io.IOException: proguard.ParseException: Unknown option '-android' in line 31 of file '/Users/yushuifeng/workspace/cccx_app_3.0/app/proguard-rules.pro'
:app:transformClassesAndResourcesWithProguardForRelease FAILED
why?
I add this option because the official website says
-android
Specifies that the processed class files are targeted at the Android platform. ProGuard then makes sure some features are compatible with Android. For example, you should specify this option if you are processing an Android application.
refs:https://www.guardsquare.com/en/proguard/manual/usage#preverificationoptions
sorry I don't know how to format the text,so I can post my code in proguard-rules.pro file, just a standard proguard with an additional option
-android
Try adding -ignorewarnings in your proguard-rules.pro file, then clean & build your project.
The option -android was added in ProGuard 6.0. It is very likely that your standard gradle setup uses a different version of ProGuard. The version being used should be printed if you enable -i for your gradle build and possibly add -verbose to your proguard rules.

How to obfuscate android .apk file using proguard using android studio?

I want to obfuscate my android apk file using proguard or any other method. tried many ways including :-
copy-pasting proguard.txt and proguard-optimise.txt file from sdk folder (sdk-tools-progurad) to my app module within the project directory
I have written minifyEnabled=true in gradle file of app.
After doing so facing further issue of some proguard errors giving warnings for external library class files.
Error: -Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Please correct the above warnings first.
Even I am unable to generate signed apk.
It is strongly advised to investigate the warnings that ProGuard prints to the console and try to fix them. For this you will have to either include additional libraries or add -dontwarn directives to your proguard-project.txt file.
As a last resort, you can also use -ignorewarnings which will instruct ProGuard to continue regardless of any remaining warning.

android signed apk / net.sourceforge.jtds errors

I'm trying to build a signed apk (release) using proguard, but when generating the APK android studio reports several warnings related to "net.sourceforge.jtds" like this:
Warning:net.sourceforge.jtds.jdbcx.JtdsDataSource: can't find superclass or interface javax.sql.XADataSource
Warning:net.sourceforge.jtds.jdbcx.JtdsDataSource: can't find superclass or interface javax.naming.Referenceable
...
and finally ends with an error:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Please correct the above warnings first.
do I have to configure proguard to "ignore" jtds? how ?
any help would be greatly appreciated.
The warning means that you are missing some dependent libraries. The missing classes (javax.naming.Referenceable or javax.sql.XADataSource) are present in a standard Java 7 SDK, but not in the android.jar (as you are building for android).
I am not aware if the used library (jtds) works well with Android, but in case it does you can add the following to your configuration to instruct ProGuard to ignore the warnings:
-dontwarn net.sourceforge.jtds.**
Otherwise you might need to add the missing libraries for android, e.g. jndi.

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).

Categories

Resources