From 27d6ffadd9adbaadec777dc08d36609393e8b50c Mon Sep 17 00:00:00 2001 From: Phillip Hsu Date: Fri, 23 Sep 2016 21:17:12 -0700 Subject: [PATCH] Prepare release build variant --- .gitignore | 1 + app/build.gradle | 37 +++++++++++++++++++++++++++++++++++-- app/proguard-rules.pro | 21 +++++++++++++++++++++ keystore.properties | 4 ++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 keystore.properties diff --git a/.gitignore b/.gitignore index c6cbe56..a4d6f98 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ .DS_Store /build /captures +/keystore.properties diff --git a/app/build.gradle b/app/build.gradle index 03915ba..139271b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,30 @@ apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' +// ============================================================================= +// https://developer.android.com/studio/publish/app-signing.html#secure-shared-keystore + +// Create a variable called keystorePropertiesFile, and initialize it to your +// keystore.properties file, in the rootProject folder. +def keystorePropertiesFile = rootProject.file("keystore.properties") + +// Initialize a new Properties() object called keystoreProperties. +def keystoreProperties = new Properties() + +// Load your keystore.properties file into the keystoreProperties object. +keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + +// ============================================================================= + android { + signingConfigs { + config { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } + } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { @@ -16,8 +39,17 @@ android { } buildTypes { release { + // https://developer.android.com/studio/build/shrink-code.html#shrink-code + // + // Proguard is disabled, because it seems like it is removing + // ButterKnife generated code and I don't know how to fix it... minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + // "'proguard-android-optimize.txt' includes the same ProGuard rules + // [as 'proguard-android.txt'], but with other optimizations that + // perform analysis at the bytecode level—inside and across methods— + // to reduce your APK size further and help it run faster." + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.config } } productFlavors { @@ -28,7 +60,8 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' - testCompile 'org.robolectric:robolectric:3.0' // TODO: delete, not in use + // TODO: delete, not in use + testCompile 'org.robolectric:robolectric:3.0' provided 'com.google.auto.value:auto-value:1.2' apt 'com.google.auto.value:auto-value:1.2' compile 'com.android.support:appcompat-v7:23.4.0' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6e37b71..319e92e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -15,3 +15,24 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} + +# https://guides.codepath.com/android/Publishing-to-the-Play-Store +-assumenosideeffects class android.util.Log { + public static boolean isLoggable(java.lang.String, int); + public static int v(...); + public static int i(...); + public static int w(...); + public static int d(...); + public static int e(...); +} + +# https://github.com/JakeWharton/butterknife/issues/409 +# https://github.com/JakeWharton/butterknife/blob/master/butterknife/proguard-rules.txt +# Retain generated class which implement Unbinder. +-keep public class * implements butterknife.Unbinder { public (...); } + +# Prevent obfuscation of types which use ButterKnife annotations since the simple name +# is used to reflectively look up the generated ViewBinding. +-keep class butterknife.* +-keepclasseswithmembernames class * { @butterknife.* ; } +-keepclasseswithmembernames class * { @butterknife.* ; } \ No newline at end of file diff --git a/keystore.properties b/keystore.properties new file mode 100644 index 0000000..6bf09e1 --- /dev/null +++ b/keystore.properties @@ -0,0 +1,4 @@ +storePassword=fkclahs9 +keyPassword=fkclahs9 +keyAlias=ClockPlusAppKey +storeFile=C\:\\Users\\Phillip Hsu\\AndroidStudioProjects\\keystore_clockplus_app.jks \ No newline at end of file