Skip to content

Commit

Permalink
Updated/optimised proguard rules.
Browse files Browse the repository at this point in the history
Removed a bunch of rules from the project’s proguard file. It looks like we were being overzealous in what progaurd was keeping, resulting in a less-than optimal proguard run.

This change gets us back under the dex method limit (back to around 51k methods).
  • Loading branch information
timusus committed Apr 19, 2017
1 parent 94ef6b2 commit f45719a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 145 deletions.
6 changes: 5 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ android {
}

release {

minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')

// For further optimisation, use 'proguard-android-optimize.txt' instead of 'proguard-android.txt'.
// Last time I checked, it reduced by another ~5000 methods.
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.pro')
signingConfig signingConfigs.release

buildConfigField("String", "LASTFM_API_KEY", "\"${getProperty(getProperties('../private.properties'), 'LASTFM_API_KEY')}\"")
Expand Down
144 changes: 0 additions & 144 deletions app/proguard-project.txt

This file was deleted.

79 changes: 79 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/tim/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
-renamesourcefileattribute SourceFile

# Add any project specific keep options here:

# Allow obfuscation of android.support.v7.internal.view.menu.**
# to avoid problem on Samsung 4.2.2 devices with appcompat v21
# see https://code.google.com/p/android/issues/detail?id=78377
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}

# Custom MediaRouteActionProvider, referenced via menu action view class
-keep class com.simplecity.amp_library.ui.views.MyMediaRouteActionProvider { *; }

# Glide
-keep public class * implements com.bumptech.glide.module.GlideModule

# JAudioTagger
-dontwarn org.jaudiotagger.**

# RetroLambda
-dontwarn java.lang.invoke.*

# OkHttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp3.** { *; }
-keep interface com.squareup.okhttp3.** { *; }
-dontwarn com.squareup.okhttp3.**

# Okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**

# Retrofit
-dontwarn rx.**
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}

# Build is failing without the following.. Something to do with StreamSupport?
-dontwarn java8.**

# RXJava
-dontwarn sun.misc.**

-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
}

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
}

# Hide an annoying compilation warning
# http://stackoverflow.com/questions/3308010/what-is-the-ignoring-innerclasses-attribute-warning-output-during-compilation
-keepattributes EnclosingMethod

0 comments on commit f45719a

Please sign in to comment.