krschultz / android-proguard-snippets Goto Github PK
View Code? Open in Web Editor NEWProguard configurations for common Android libraries
Home Page: http://www.kevinrschultz.com/blog/2014/02/15/proguard-with-gradle/
License: Apache License 2.0
Proguard configurations for common Android libraries
Home Page: http://www.kevinrschultz.com/blog/2014/02/15/proguard-with-gradle/
License: Apache License 2.0
`org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesAndResourcesWithProguardForRc'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Job failed, see logs for details
at com.android.build.gradle.internal.transforms.ProGuardTransform.transform(ProGuardTransform.java:196)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:221)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 32 more
Caused by: java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:473)
at proguard.ProGuard.initialize(ProGuard.java:233)
at proguard.ProGuard.execute(ProGuard.java:98)
at com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:61)
at com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:253)
at com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:63)
at com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:173)
at com.android.builder.tasks.Job.runTask(Job.java:47)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:282)
... 1 more
`
As shown here: https://github.com/evant/gradle-retrolambda#proguard
You need a -dontwarn for retrolambda:
-dontwarn java.lang.invoke.*
Is there a proguard snippet for Leak Canary (https://github.com/square/leakcanary)?
Instead of a generic catch-all for "common" testing libs (https://github.com/krschultz/android-proguard-snippets/blob/c636c6c8448565e91e25a66f11fab3fca035c29c/examples/proguard-project-test.pro), add specific proguard files for known testing libs (espresso, robolectric, junit, etc)
The thrown message when syncing the gradle project is
Error:(110, 0) Cannot convert the provided notation to a File or URI: file collection.
The following types/formats are supported:
- A String or CharSequence path, for example 'src/main/java' or '/usr/include'.
- A String or CharSequence URI, for example 'file:/usr/include'.
- A File instance.
- A URI or URL instance.
<a href="openFile:/Users/roc/Projects/AndroidStudio/bluejobs-app/app/build.gradle">Open File</a>
The guava snippet didn't work for me. As described I added
provided 'javax.annotation:jsr250-api:1.0'
to my dependecies.
But that didn't help. So I added
-dontwarn javax.annotation.**
-dontwarn sun.misc.Unsafe
to proguard-guava.pro
FileCollection proGuardFileCollection = files { file('./cproguardfiles').listFiles() }
proguardFiles(proGuardFileCollection)
Folder name is: cproguardfiles(in project structure )
Error:(23, 0) Cannot convert the provided notation to a File or URI: file collection.
The following types/formats are supported:
the automatic generated and hidden file DS_Store is making the build fail when using the script to include all ProGuard files from a specific folder.
com.android.support:multidex:1.0.1
com.jakewharton.rxbinding:rxbinding:0.2.0
com.squareup.retrofit:converter-gson:2.0.0-beta2
com.wdullaer:materialdatetimepicker:2.0.2
com.readystatesoftware.systembartint:systembartint:1.0.3
com.umeng:fb:5.4.0
my email is [email protected]
Hey guys do you have any ideas for implementation of Jackson JSON Processor.Would appreciate if you guys included it!
Hi,
Any luck with http://square.github.io/dagger/ ?
Hi,
GreenDAO 3 comes with new package name.
de.greenrobot.dao.AbstractDao becomes org.greenrobot.greendao.AbstractDao.
Regards
It would be awesome to have the configuration for Admob, the one on the site does not work for proguard with optimize
Note: ProGuard directives are included in the Play services client libraries to preserve the required classes. The Android Plugin for Gradle automatically appends ProGuard configuration files in an AAR (Android ARchive) package and appends that package to your ProGuard configuration. During project creation, Android Studio automatically creates the ProGuard configuration files and build.gradle properties for ProGuard use. To use ProGuard with Android Studio, you must enable the ProGuard setting in your build.gradle buildTypes. For more information, see the ProGuard guide.
https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project
Libraries built with gradle can have consumerProguardFiles, which will be added in application itself. Google Play Services does that (as per Ian Lake's google+ post, when Google play services 7.5 are added). I have added consumer proguard line in one of my libraries here
How about having an aar built around these files? people don't have to download all the files separately and adding manually? Just add a library as dependency and it should take care of keep classes in proguard. In my knowledge it won't add anything to final apk, as we're not adding any code into the library, just build logic. I am proposing aar because I am familiar with developing gradle plugins and on the other hand I am not aware about adding consumerProguardFiles
programatically from plugins.
Only downside I can see is the library size itself is too big provided there are too many files. But as I have stated above it should not add any footprint to final apk size. So, are we going to have aar library around that?
Library name: Parceler
Library url: https://github.com/johncarl81/parceler
# Parcel library
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class org.parceler.Parceler$$Parcels
Hi There,
I have just spotted that GSON proguard has jota related code.
-keep class org.joda.time.** { ; }
-keep interface org.joda.time.* { ; }
-keep class org.joda.convert.* { ; }
-keep interface org.joda.convert.* { *; }
Just put it here to get your attention.
Thanks,
Tony
Hi,
I have pro-guard rule file for my app ..I am having obfuscation for Variables & methods .
I want to obfuscate my class and activity name...
The proguard lines mentioned in Butterknife documentation have some differences from the ones in the snippets. Any reason for that?
I have included circular progress button to my project. The problem is that once i enable proguard animations does no work properly. I have all kind of proguard config but no success yet. So i would be very appreciated if you find some eay to work around this
Should I include it?
I mentions project.properties
which is very outdated.
However, it includes useful things like -keep class android.support.v4.** { *; }
which includes Support Fragment
See this line:
https://github.com/krschultz/android-proguard-snippets/blob/master/libraries/proguard-guava.pro#L7
according to: https://code.google.com/p/guava-libraries/wiki/UsingProGuardWithGuava
You must in use jsr305.jar not jsr250
first apologize that I'm lazy to make a pull request...
api23+ is building with OpenJDK instead of Oracle JDK, which doesn't have sun.misc.Unsafe.
adding
-dontwarn com.google.common.cache.**
-dontwarn com.google.common.primitives.UnsignedBytes$**
to proguard-google-play-services.pro
fixes warning:
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$1: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.cache.Striped64$Cell: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator: can't find referenced class sun.misc.Unsafe
Warning: com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator$1: can't find referenced class sun.misc.Unsafe
which renderes "Generate signed APK" to fail.
I dunno what side-effects would this introduce, tho.
I discovered that with current Guava configuration ProGuard removes annotated EventBus subscriber methods and so events are fired but not consumed.
This rule fixes this issue:
-keepclassmembers class ** {
@com.google.common.eventbus.Subscribe public *;
}
Hi, you could add the proguard config to avoid a bug in some samsung phones
https://code.google.com/p/android/issues/detail?id=78377
something like this
# https://phabricator.wikimedia.org/T78197:
# NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder
# http://stackoverflow.com/questions/26657348/appcompat-v7-v21-0-0-causing-crash-on-samsung-devices-with-android-v4-2-2
# Allow obfuscation of android.support.v7.internal.view.menu.** but not the rest of android.support
# to avoid problem on Samsung 4.2.2 devices with appcompat v21
# see https://code.google.com/p/android/issues/detail?id=78377#hc150
-keep class !android.support.v7.internal.view.menu.MenuBuilder
-keep class !android.support.v7.internal.view.menu.SubMenuBuilder
from: https://github.com/wikimedia/apps-android-wikipedia/blob/master/wikipedia/proguard-rules.pro
http://developer.samsung.com/resources/pass
Maybe nobody is using it but they don't have a solution out-of-the-box. I'll try to paste it here if I find a solution...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.