Sweeping update of gradle and dependency versions. (#1858)

* Sweeping update of gradle and library versions.

This updates all of the dependencies of the project to their latest
versions. Everyone should please upgrade to the latest version of Android
Studio, update your build tools, and keep your version of Gradle and the
Kotlin plugin up to date.

* Update build tools in travis.

* Remove cruft and fix tests.

* Remove even more stuff.

* Reinstate instrumented tests.

* Update emulator image in travis.

* Localisation updates from https://translatewiki.net.

* Work towards eliminating string literals from code. (#1861)

String literals are being used in many places in the code, instead of
proper string resources which are automatically localized. This PR
replaces many of the string literals with pre-packaged resources, or will
add the appropriate string if necessary.

* Add button on image details to copy wikicode to clipboard (#1849)

* Add button on image details to copy wikicode to clipboard

* Make copy wikicode button width the same as the nominate deletion button width by filling in background

* Build fix

* Enable ProGuard for Debug and Release builds.

This enables ProGuard minification, which significantly shrinks the APK
(for both debug and release configurations) and vastly decreases the
method count.

* Add ProGuard rules for test builds.
This commit is contained in:
Dmitry Brant 2018-09-11 04:51:28 -04:00 committed by neslihanturan
parent 1dd7cbb614
commit fc30f1b5ec
12 changed files with 112 additions and 63 deletions

View file

@ -1,6 +0,0 @@
[gerrit]
host=gerrit.wikimedia.org
port=29418
project=apps/android/commons.git
defaultbranch=master
defaultrebase=0

View file

@ -12,19 +12,16 @@ env:
- ADB_INSTALL_TIMEOUT=12 # in minutes
jdk:
# - openjdk8 # not yet available
- oraclejdk8
android:
components:
- tools
- platform-tools
- build-tools-27.0.0
- build-tools-27.0.3
- extra-google-m2repository
- extra-android-m2repository
- ${ANDROID_TARGET}
- android-25
- android-26
- android-22
- android-27
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
licenses:

View file

@ -4,7 +4,6 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'jacoco-android'
apply from: 'quality.gradle'
apply plugin: 'com.getkeepsafe.dexcount'
dependencies {
implementation 'com.prof.rssparser:rssparser:1.1'
@ -16,12 +15,12 @@ dependencies {
implementation 'org.mediawiki:api:1.3'
implementation 'commons-codec:commons-codec:1.10'
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.jakewharton.timber:timber:4.5.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.jakewharton.timber:timber:4.6.0'
implementation 'info.debatty:java-string-similarity:0.24'
implementation 'com.borjabravo:readmoretextview:2.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') {
transitive = true
}
@ -34,35 +33,35 @@ dependencies {
implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION"
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
implementation 'com.squareup.okio:okio:1.13.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okio:okio:1.14.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.facebook.fresco:fresco:1.5.0'
implementation 'com.facebook.fresco:fresco:1.10.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation 'junit:junit:4.12'
testImplementation 'org.robolectric:robolectric:3.7.1'
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
implementation 'com.tspoon.traceur:traceur:1.0.1'
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
androidTestImplementation "com.android.support:support-annotations:$SUPPORT_LIB_VERSION"
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
@ -81,16 +80,14 @@ android {
compileSdkVersion project.compileSdkVersion
buildToolsVersion project.buildToolsVersion
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'fr.free.nrw.commons'
versionCode 90
versionName '2.8.3'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
minSdkVersion project.minSdkVersion
targetSdkVersion project.targetSdkVersion
minSdkVersion 15
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
@ -112,11 +109,15 @@ android {
buildTypes {
release {
minifyEnabled false // See https://stackoverflow.com/questions/40232404/google-play-apk-and-android-studio-apk-usb-debug-behaving-differently - proguard.cfg modification alone insufficient.
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
testProguardFile 'test-proguard-rules.txt'
}
debug {
minifyEnabled true
testCoverageEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
testProguardFile 'test-proguard-rules.txt'
versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion()
}
}
@ -189,11 +190,5 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
//FIXME: Temporary fix for https://github.com/commons-app/apps-android-commons/issues/709
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:25.2.0'
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
buildToolsVersion buildToolsVersion
}

Binary file not shown.

View file

@ -1,4 +1,58 @@
-dontobfuscate
-ignorewarnings
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-keep class android.support.v7.widget.ShareActionProvider { *; }
# --- Butter Knife ---
# Finder.castParam() is stripped when not needed and ProGuard notes it
# unnecessarily. When castParam() is needed, it's not stripped. e.g.:
#
# @OnItemSelected(value = R.id.history_entry_list)
# void foo(ListView bar) {
# L.d("baz");
# }
-dontnote butterknife.internal.**
# --- /Butter Knife ---
# --- Retrofit2 ---
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain declared checked exceptions for use by a Proxy instance.
-keepattributes Exceptions
# --- /Retrofit ---
# --- OkHttp + Okio ---
-dontwarn okhttp3.**
-dontwarn okio.**
# --- /OkHttp + Okio ---
# --- Gson ---
# https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }
# Prevent proguard from stripping interface information from TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# --- /Gson ---

View file

@ -97,19 +97,25 @@ public class CommonsApplication extends Application {
.getInstance(this)
.getCommonsApplicationComponent()
.inject(this);
Timber.plant(new Timber.DebugTree());
// Set DownsampleEnabled to True to downsample the image in case it's heavy
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this,config);
try {
Fresco.initialize(this, config);
} catch (Exception e) {
Timber.e(e);
// TODO: Remove when we're able to initialize Fresco in test builds.
}
if (setupLeakCanary() == RefWatcher.DISABLED) {
return;
}
// Empty temp directory in case some temp files are created and never removed.
ContributionUtils.emptyTemporaryDirectory();
Timber.plant(new Timber.DebugTree());
if (!BuildConfig.DEBUG) {
ACRA.init(this);
} else {

View file

@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.support.graphics.drawable.VectorDrawableCompat;
@ -135,9 +136,14 @@ public class NearbyController {
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
VectorDrawableCompat vectorDrawable = null;
try {
vectorDrawable = VectorDrawableCompat.create(
context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme()
);
} catch (Resources.NotFoundException e) {
// ignore when running tests.
}
if (vectorDrawable != null) {
Bitmap icon = UiUtils.getBitmap(vectorDrawable);

View file

@ -10,7 +10,7 @@ import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(constants = BuildConfig::class, sdk = intArrayOf(21), application = TestCommonsApplication::class)
@Config(constants = BuildConfig::class, sdk = [21], application = TestCommonsApplication::class)
class NearbyControllerTest {
@Test

View file

@ -0,0 +1,4 @@
-dontobfuscate
-dontoptimize
-dontshrink
-ignorewarnings

View file

@ -1,15 +1,15 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.31'
ext.kotlin_version = '1.2.60'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.1'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View file

@ -15,18 +15,11 @@
#Thu Mar 01 15:28:48 IST 2018
systemProp.http.proxyPort=0
compileSdkVersion=android-27
android.useDeprecatedNdk=true
BUTTERKNIFE_VERSION=8.6.0
BUTTERKNIFE_VERSION=8.8.1
org.gradle.jvmargs=-Xmx1536M
buildToolsVersion=27.0.0
targetSdkVersion=27
buildToolsVersion=27.0.3
#TODO: Temporary disabled. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2
#Refer to PR: https://github.com/commons-app/apps-android-commons/pull/932
android.enableAapt2=false
SUPPORT_LIB_VERSION=27.1.1
minSdkVersion=15
systemProp.http.proxyHost=
LEAK_CANARY=1.5.4
DAGGER_VERSION=2.13
gradleVersion=3.0.0
DAGGER_VERSION=2.15

View file

@ -1,6 +1,6 @@
#Sat Mar 03 13:58:47 IST 2018
#Sat Aug 25 23:38:03 EDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip