Release, and minify apk/use proguard properly

This commit is contained in:
Matthieu 2021-01-25 20:41:00 +01:00
parent 6084ecda89
commit ed5b780ee6
3 changed files with 73 additions and 25 deletions

View File

@ -24,8 +24,8 @@ android {
applicationId "com.h.pixeldroid" applicationId "com.h.pixeldroid"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 30 targetSdkVersion 30
versionCode 9 versionCode 10
versionName "1.0.alpha8" versionName "1.0.alpha9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true' testInstrumentationRunnerArguments clearPackageData: 'true'
@ -46,8 +46,10 @@ android {
testCoverageEnabled true testCoverageEnabled true
} }
release { release {
minifyEnabled false minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' shrinkResources true
useProguard true
proguardFiles 'proguard-rules.pro'
} }
} }
testOptions { testOptions {
@ -64,7 +66,6 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
/** /**
* AndroidX dependencies: * AndroidX dependencies:
@ -80,7 +81,7 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha11' implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"

View File

@ -1,21 +1,68 @@
# Add project specific ProGuard rules here. # proguard file largely copied from Tusky's
# You can control the set of applied configuration files using the # GENERAL OPTIONS (inspired from AOSP's proguard-android-optimize.txt)
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following # turn on all optimizations except those that are known to cause problems on Android
# and specify the fully qualified class name to the JavaScript interface -optimizations !code/simplification/cast,!field/*,!class/merging/*
# class: -optimizationpasses 6
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -allowaccessmodification
# public *; -dontpreverify
#}
# Uncomment this to preserve the line number information for -dontusemixedcaseclassnames
# debugging stack traces. -dontskipnonpubliclibraryclasses
#-keepattributes SourceFile,LineNumberTable -keepattributes *Annotation*
# If you keep the line number information, uncomment this to # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
# hide the original source file name. -keepclasseswithmembernames class * {
#-renamesourcefileattribute SourceFile native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepclassmembers class * implements android.os.Parcelable {
public static final ** CREATOR;
}
# APP SPECIFIC OPTIONS
# keep members of our model classes, they are used in json de/serialization
-keepclassmembers class com.h.pixeldroid.utils.api.objects.* { *; }
-keep public enum com.h.pixeldroid.utils.api.objects.*$** {
**[] $VALUES;
public *;
}
# preserve line numbers for crash reporting
-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile
# remove all logging from production apk
-assumenosideeffects class android.util.Log {
public static *** getStackTraceString(...);
public static *** d(...);
public static *** w(...);
public static *** v(...);
public static *** i(...);
}
-assumenosideeffects class java.lang.String {
public static java.lang.String format(...);
}
# remove some kotlin overhead
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
static void checkExpressionValueIsNotNull(java.lang.Object, java.lang.String);
static void throwUninitializedPropertyAccessException(java.lang.String);
}

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.1' classpath 'com.android.tools.build:gradle:4.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong