Skip to content

Commit fc30f1b

Browse files
dbrantneslihanturan
authored andcommitted
Sweeping update of gradle and dependency versions. (commons-app#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. (commons-app#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 (commons-app#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.
1 parent 1dd7cbb commit fc30f1b

File tree

12 files changed

+112
-63
lines changed

12 files changed

+112
-63
lines changed

.gitreview

-6
This file was deleted.

.travis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ env:
1212
- ADB_INSTALL_TIMEOUT=12 # in minutes
1313

1414
jdk:
15-
# - openjdk8 # not yet available
1615
- oraclejdk8
1716

1817
android:
1918
components:
2019
- tools
2120
- platform-tools
22-
- build-tools-27.0.0
21+
- build-tools-27.0.3
2322
- extra-google-m2repository
2423
- extra-android-m2repository
25-
- ${ANDROID_TARGET}
26-
- android-25
27-
- android-26
24+
- android-22
2825
- android-27
2926
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
3027
licenses:

app/build.gradle

+23-28
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ apply plugin: 'kotlin-android'
44
apply plugin: 'kotlin-kapt'
55
apply plugin: 'jacoco-android'
66
apply from: 'quality.gradle'
7-
apply plugin: 'com.getkeepsafe.dexcount'
87

98
dependencies {
109
implementation 'com.prof.rssparser:rssparser:1.1'
@@ -16,12 +15,12 @@ dependencies {
1615
implementation 'org.mediawiki:api:1.3'
1716
implementation 'commons-codec:commons-codec:1.10'
1817
implementation 'com.github.pedrovgs:renderers:3.3.3'
19-
implementation 'com.google.code.gson:gson:2.8.1'
20-
implementation 'com.jakewharton.timber:timber:4.5.1'
18+
implementation 'com.google.code.gson:gson:2.8.5'
19+
implementation 'com.jakewharton.timber:timber:4.6.0'
2120
implementation 'info.debatty:java-string-similarity:0.24'
2221
implementation 'com.borjabravo:readmoretextview:2.1.0'
2322

24-
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
23+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
2524
implementation('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0@aar') {
2625
transitive = true
2726
}
@@ -34,35 +33,35 @@ dependencies {
3433
implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION"
3534
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
3635
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
37-
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
38-
implementation 'com.squareup.okio:okio:1.13.0'
39-
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
36+
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
37+
implementation 'com.squareup.okio:okio:1.14.0'
38+
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
4039
// Because RxAndroid releases are few and far between, it is recommended you also
4140
// explicitly depend on RxJava's latest version for bug fixes and new features.
42-
implementation 'io.reactivex.rxjava2:rxjava:2.1.2'
43-
implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
44-
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0'
45-
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
46-
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
41+
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
42+
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
43+
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.1.1'
44+
implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1'
45+
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.1.1'
4746
implementation 'org.jsoup:jsoup:1.11.3'
48-
implementation 'com.facebook.fresco:fresco:1.5.0'
47+
implementation 'com.facebook.fresco:fresco:1.10.0'
4948
implementation 'com.facebook.stetho:stetho:1.5.0'
5049
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
5150
implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
5251
kapt "com.google.dagger:dagger-android-processor:$DAGGER_VERSION"
5352
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
54-
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
53+
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
5554
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
5655
testImplementation 'junit:junit:4.12'
5756
testImplementation 'org.robolectric:robolectric:3.7.1'
5857
testImplementation 'com.nhaarman:mockito-kotlin:1.5.0'
59-
testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
58+
testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
6059
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
6160

6261
implementation 'com.tspoon.traceur:traceur:1.0.1'
6362

64-
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
65-
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1'
63+
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64+
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0'
6665
androidTestImplementation "com.android.support:support-annotations:$SUPPORT_LIB_VERSION"
6766
androidTestImplementation 'com.android.support.test:rules:1.0.2'
6867
androidTestImplementation 'com.android.support.test:runner:1.0.2'
@@ -81,16 +80,14 @@ android {
8180
compileSdkVersion project.compileSdkVersion
8281
buildToolsVersion project.buildToolsVersion
8382

84-
useLibrary 'org.apache.http.legacy'
85-
8683
defaultConfig {
8784
applicationId 'fr.free.nrw.commons'
8885
versionCode 90
8986
versionName '2.8.3'
9087
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
9188

92-
minSdkVersion project.minSdkVersion
93-
targetSdkVersion project.targetSdkVersion
89+
minSdkVersion 15
90+
targetSdkVersion 27
9491
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
9592
vectorDrawables.useSupportLibrary = true
9693
}
@@ -112,11 +109,15 @@ android {
112109

113110
buildTypes {
114111
release {
115-
minifyEnabled false // See https://stackoverflow.com/questions/40232404/google-play-apk-and-android-studio-apk-usb-debug-behaving-differently - proguard.cfg modification alone insufficient.
112+
minifyEnabled true
116113
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
114+
testProguardFile 'test-proguard-rules.txt'
117115
}
118116
debug {
117+
minifyEnabled true
119118
testCoverageEnabled true
119+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
120+
testProguardFile 'test-proguard-rules.txt'
120121
versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion()
121122
}
122123
}
@@ -189,11 +190,5 @@ android {
189190
targetCompatibility JavaVersion.VERSION_1_8
190191
}
191192

192-
//FIXME: Temporary fix for https://github.com/commons-app/apps-android-commons/issues/709
193-
configurations.all {
194-
resolutionStrategy.force 'com.android.support:support-annotations:25.2.0'
195-
exclude module: 'httpclient'
196-
exclude module: 'commons-logging'
197-
}
198193
buildToolsVersion buildToolsVersion
199194
}

app/libs/java-json.jar

-82.7 KB
Binary file not shown.

app/proguard-rules.txt

+55-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,58 @@
11
-dontobfuscate
2+
-ignorewarnings
3+
24
-keep class org.apache.http.** { *; }
35
-dontwarn org.apache.http.**
4-
-keep class android.support.v7.widget.ShareActionProvider { *; }
6+
-keep class android.support.v7.widget.ShareActionProvider { *; }
7+
8+
# --- Butter Knife ---
9+
# Finder.castParam() is stripped when not needed and ProGuard notes it
10+
# unnecessarily. When castParam() is needed, it's not stripped. e.g.:
11+
#
12+
# @OnItemSelected(value = R.id.history_entry_list)
13+
# void foo(ListView bar) {
14+
# L.d("baz");
15+
# }
16+
17+
-dontnote butterknife.internal.**
18+
# --- /Butter Knife ---
19+
20+
# --- Retrofit2 ---
21+
# Platform calls Class.forName on types which do not exist on Android to determine platform.
22+
-dontnote retrofit2.Platform
23+
# Platform used when running on Java 8 VMs. Will not be used at runtime.
24+
-dontwarn retrofit2.Platform$Java8
25+
# Retain generic type information for use by reflection by converters and adapters.
26+
-keepattributes Signature
27+
# Retain declared checked exceptions for use by a Proxy instance.
28+
-keepattributes Exceptions
29+
# --- /Retrofit ---
30+
31+
# --- OkHttp + Okio ---
32+
-dontwarn okhttp3.**
33+
-dontwarn okio.**
34+
# --- /OkHttp + Okio ---
35+
36+
# --- Gson ---
37+
# https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg
38+
39+
# Gson uses generic type information stored in a class file when working with fields. Proguard
40+
# removes such information by default, so configure it to keep all of it.
41+
-keepattributes Signature
42+
43+
# For using GSON @Expose annotation
44+
-keepattributes *Annotation*
45+
46+
# Gson specific classes
47+
-dontwarn sun.misc.**
48+
#-keep class com.google.gson.stream.** { *; }
49+
50+
# Application classes that will be serialized/deserialized over Gson
51+
-keep class com.google.gson.examples.android.model.** { *; }
52+
53+
# Prevent proguard from stripping interface information from TypeAdapterFactory,
54+
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
55+
-keep class * implements com.google.gson.TypeAdapterFactory
56+
-keep class * implements com.google.gson.JsonSerializer
57+
-keep class * implements com.google.gson.JsonDeserializer
58+
# --- /Gson ---

app/src/main/java/fr/free/nrw/commons/CommonsApplication.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,25 @@ public void onCreate() {
9797
.getInstance(this)
9898
.getCommonsApplicationComponent()
9999
.inject(this);
100+
101+
Timber.plant(new Timber.DebugTree());
102+
100103
// Set DownsampleEnabled to True to downsample the image in case it's heavy
101104
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
102105
.setDownsampleEnabled(true)
103106
.build();
104-
Fresco.initialize(this,config);
107+
try {
108+
Fresco.initialize(this, config);
109+
} catch (Exception e) {
110+
Timber.e(e);
111+
// TODO: Remove when we're able to initialize Fresco in test builds.
112+
}
105113
if (setupLeakCanary() == RefWatcher.DISABLED) {
106114
return;
107115
}
108116
// Empty temp directory in case some temp files are created and never removed.
109117
ContributionUtils.emptyTemporaryDirectory();
110118

111-
Timber.plant(new Timber.DebugTree());
112-
113119
if (!BuildConfig.DEBUG) {
114120
ACRA.init(this);
115121
} else {

app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.Context;
44
import android.content.SharedPreferences;
5+
import android.content.res.Resources;
56
import android.graphics.Bitmap;
67
import android.support.graphics.drawable.VectorDrawableCompat;
78

@@ -135,9 +136,14 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
135136

136137
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
137138

138-
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
139-
context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme()
140-
);
139+
VectorDrawableCompat vectorDrawable = null;
140+
try {
141+
vectorDrawable = VectorDrawableCompat.create(
142+
context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme()
143+
);
144+
} catch (Resources.NotFoundException e) {
145+
// ignore when running tests.
146+
}
141147
if (vectorDrawable != null) {
142148
Bitmap icon = UiUtils.getBitmap(vectorDrawable);
143149

app/src/test/kotlin/fr/free/nrw/commons/NearbyControllerTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.robolectric.RuntimeEnvironment
1010
import org.robolectric.annotation.Config
1111

1212
@RunWith(RobolectricTestRunner::class)
13-
@Config(constants = BuildConfig::class, sdk = intArrayOf(21), application = TestCommonsApplication::class)
13+
@Config(constants = BuildConfig::class, sdk = [21], application = TestCommonsApplication::class)
1414
class NearbyControllerTest {
1515

1616
@Test

app/test-proguard-rules.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-dontobfuscate
2+
-dontoptimize
3+
-dontshrink
4+
-ignorewarnings

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = '1.2.31'
3+
ext.kotlin_version = '1.2.60'
44
repositories {
55
jcenter()
66
mavenCentral()
77
google()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.0.1'
11-
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1'
12-
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.1'
10+
classpath 'com.android.tools.build:gradle:3.1.4'
11+
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.3'
12+
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}

gradle.properties

+3-10
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,11 @@
1515
#Thu Mar 01 15:28:48 IST 2018
1616
systemProp.http.proxyPort=0
1717
compileSdkVersion=android-27
18-
android.useDeprecatedNdk=true
19-
BUTTERKNIFE_VERSION=8.6.0
18+
BUTTERKNIFE_VERSION=8.8.1
2019
org.gradle.jvmargs=-Xmx1536M
21-
buildToolsVersion=27.0.0
22-
targetSdkVersion=27
20+
buildToolsVersion=27.0.3
2321

24-
#TODO: Temporary disabled. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2
25-
#Refer to PR: https://github.com/commons-app/apps-android-commons/pull/932
26-
android.enableAapt2=false
2722
SUPPORT_LIB_VERSION=27.1.1
28-
minSdkVersion=15
2923
systemProp.http.proxyHost=
3024
LEAK_CANARY=1.5.4
31-
DAGGER_VERSION=2.13
32-
gradleVersion=3.0.0
25+
DAGGER_VERSION=2.15
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Mar 03 13:58:47 IST 2018
1+
#Sat Aug 25 23:38:03 EDT 2018
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

0 commit comments

Comments
 (0)