From 3adb5d83aec1215bbbb2ff7ec61d96652ff55cc6 Mon Sep 17 00:00:00 2001 From: maskara Date: Thu, 2 Nov 2017 02:57:09 +0530 Subject: [PATCH 1/5] Update Gradle plugin to 3.0 --- .travis.yml | 2 +- app/build.gradle | 71 ++++++++++++------------ build.gradle | 2 + gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 3 +- 5 files changed, 44 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index aaf3ab7f9..74eecbaf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ android: components: - tools - platform-tools - - build-tools-26.0.1 + - build-tools-26.0.2 - extra-google-m2repository - extra-android-m2repository - ${ANDROID_TARGET} diff --git a/app/build.gradle b/app/build.gradle index 9baaed622..2ead26256 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,56 +1,55 @@ apply plugin: 'com.android.application' -apply plugin: 'me.tatarka.retrolambda' apply plugin: 'jacoco-android' apply from: 'quality.gradle' apply plugin: 'com.getkeepsafe.dexcount' dependencies { - compile 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07' - compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar' - compile 'in.yuvi:http.fluent:1.3' - compile 'com.android.volley:volley:1.0.0' - compile 'ch.acra:acra:4.7.0' - compile 'org.mediawiki:api:1.3' - compile 'commons-codec:commons-codec:1.10' - compile 'com.github.pedrovgs:renderers:3.3.3' - compile 'com.google.code.gson:gson:2.8.1' - compile 'com.jakewharton.timber:timber:4.5.1' - compile 'info.debatty:java-string-similarity:0.24' - compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar'){ + implementation 'com.github.nicolas-raoul:Quadtree:ac16ea8035bf07' + implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar' + implementation 'in.yuvi:http.fluent:1.3' + implementation 'com.android.volley:volley:1.0.0' + implementation 'ch.acra:acra:4.7.0' + 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 'info.debatty:java-string-similarity:0.24' + implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0@aar'){ transitive=true } - compile "com.android.support:support-v4:${project.supportLibVersion}" - compile "com.android.support:appcompat-v7:${project.supportLibVersion}" - compile "com.android.support:design:${project.supportLibVersion}" + implementation "com.android.support:support-v4:${project.supportLibVersion}" + implementation "com.android.support:appcompat-v7:${project.supportLibVersion}" + implementation "com.android.support:design:${project.supportLibVersion}" - compile "com.android.support:cardview-v7:${project.supportLibVersion}" + implementation "com.android.support:cardview-v7:${project.supportLibVersion}" - compile "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION" + implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION" annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION" - compile 'com.squareup.okhttp3:okhttp:3.8.1' - compile 'com.squareup.okio:okio:1.13.0' + implementation 'com.squareup.okhttp3:okhttp:3.8.1' + implementation 'com.squareup.okio:okio:1.13.0' - compile 'io.reactivex.rxjava2:rxandroid:2.0.1' + implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' // 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. - compile 'io.reactivex.rxjava2:rxjava:2.1.2' - compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0' - compile 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.0.0' - compile 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0' - compile 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0' + 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' - compile 'com.facebook.fresco:fresco:1.3.0' - compile 'com.facebook.stetho:stetho:1.5.0' + implementation 'com.facebook.fresco:fresco:1.3.0' + implementation 'com.facebook.stetho:stetho:1.5.0' - testCompile 'junit:junit:4.12' - testCompile 'org.robolectric:robolectric:3.4' + testImplementation 'junit:junit:4.12' + testImplementation 'org.robolectric:robolectric:3.4' - testCompile 'com.squareup.okhttp3:mockwebserver:3.8.1' - androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.8.1' - androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}" - androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1' + testImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1' + androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.8.1' + androidTestImplementation "com.android.support:support-annotations:${project.supportLibVersion}" + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' @@ -83,6 +82,7 @@ android { } } + flavorDimensions 'tier' productFlavors { prod { buildConfigField "String", "WIKIMEDIA_API_HOST", "\"https://commons.wikimedia.org/w/api.php\"" @@ -94,6 +94,7 @@ android { buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\"" buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\"" buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.org/w/index.php?title=Main_Page&welcome=yes\"" + dimension 'tier' } beta { @@ -107,6 +108,7 @@ android { buildConfigField "String", "EVENTLOG_WIKI", "\"commonswiki\"" buildConfigField "String", "SIGNUP_LANDING_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Special:CreateAccount&returnto=Main+Page&returntoquery=welcome%3Dyes\"" buildConfigField "String", "SIGNUP_SUCCESS_REDIRECTION_URL", "\"https://commons.m.wikimedia.beta.wmflabs.org/w/index.php?title=Main_Page&welcome=yes\"" + dimension 'tier' } } @@ -125,4 +127,5 @@ android { configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:25.2.0' } + buildToolsVersion buildToolsVersion } diff --git a/build.gradle b/build.gradle index 70023d85f..732be0d6e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ buildscript { repositories { jcenter() mavenCentral() + google() } dependencies { classpath "com.android.tools.build:gradle:${project.gradleVersion}" @@ -17,5 +18,6 @@ allprojects { jcenter() maven { url "https://jitpack.io" } maven { url "https://maven.google.com" } + google() } } diff --git a/gradle.properties b/gradle.properties index 4b643d02b..23aa8088f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ -gradleVersion = 2.3.3 +gradleVersion = 3.0.0 supportLibVersion = 26.1.0 compileSdkVersion = android-26 -buildToolsVersion = 26.0.1 +buildToolsVersion = 26.0.2 minSdkVersion = 15 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4dde7c991..e9e3a344e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Thu Nov 02 02:18:35 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip From 0964b05eedaa06986d9a4db6e514dcade760f0f3 Mon Sep 17 00:00:00 2001 From: Yusuke Matsubara Date: Fri, 3 Nov 2017 11:26:56 +0900 Subject: [PATCH 2/5] Disable LeakCanary for Robolectric tests See 'For Robolectric users:' https://github.com/square/leakcanary --- .../fr/free/nrw/commons/CommonsApplication.java | 16 ++++++++++------ .../free/nrw/commons/TestCommonsApplication.java | 11 +++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 app/src/test/java/fr/free/nrw/commons/TestCommonsApplication.java diff --git a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java index 4ea34b3b3..faaff749a 100644 --- a/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java +++ b/app/src/main/java/fr/free/nrw/commons/CommonsApplication.java @@ -17,6 +17,7 @@ import android.support.v4.util.LruCache; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.stetho.Stetho; import com.squareup.leakcanary.LeakCanary; +import com.squareup.leakcanary.RefWatcher; import org.acra.ACRA; import org.acra.ReportingInteractionMode; @@ -117,12 +118,8 @@ public class CommonsApplication extends Application { @Override public void onCreate() { super.onCreate(); - if (LeakCanary.isInAnalyzerProcess(this)) { - // This process is dedicated to LeakCanary for heap analysis. - // You should not init your app in this process. - return; - } - LeakCanary.install(this); + + setupLeakCanary(); Timber.plant(new Timber.DebugTree()); @@ -143,6 +140,13 @@ public class CommonsApplication extends Application { cacheData = new CacheController(); } + protected RefWatcher setupLeakCanary() { + if (LeakCanary.isInAnalyzerProcess(this)) { + return RefWatcher.DISABLED; + } + return LeakCanary.install(this); + } + /** * @return Account|null */ diff --git a/app/src/test/java/fr/free/nrw/commons/TestCommonsApplication.java b/app/src/test/java/fr/free/nrw/commons/TestCommonsApplication.java new file mode 100644 index 000000000..bf877ae95 --- /dev/null +++ b/app/src/test/java/fr/free/nrw/commons/TestCommonsApplication.java @@ -0,0 +1,11 @@ +package fr.free.nrw.commons; + +import com.squareup.leakcanary.RefWatcher; + +// This class is automatically discovered by Robolectric +public class TestCommonsApplication extends CommonsApplication { + @Override protected RefWatcher setupLeakCanary() { + // No leakcanary in unit tests. + return RefWatcher.DISABLED; + } +} From 3bc21ee51414cc5bc5d65b87ebd7c67d7d11a37c Mon Sep 17 00:00:00 2001 From: maskara Date: Sat, 4 Nov 2017 12:40:53 +0530 Subject: [PATCH 3/5] Disable AAPT 2 --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 23aa8088f..f7c4bdde9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,3 +14,4 @@ android.useDeprecatedNdk=true BUTTERKNIFE_VERSION=8.6.0 org.gradle.jvmargs=-Xmx1536M +android.enableAapt2=false \ No newline at end of file From ef56b69828f1bbe2d398704f35fc585b9e7a411b Mon Sep 17 00:00:00 2001 From: maskara Date: Sat, 4 Nov 2017 15:18:45 +0530 Subject: [PATCH 4/5] Replay deprecated symbol usage and mark AAPT todo --- app/build.gradle | 6 +++--- gradle.properties | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2ead26256..588a7da63 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -51,9 +51,9 @@ dependencies { androidTestImplementation "com.android.support:support-annotations:${project.supportLibVersion}" androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1' - releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' - testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1' + releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' + testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1' } android { diff --git a/gradle.properties b/gradle.properties index f7c4bdde9..eeb5ff880 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,4 +14,6 @@ android.useDeprecatedNdk=true BUTTERKNIFE_VERSION=8.6.0 org.gradle.jvmargs=-Xmx1536M + +#TODO: Temporary disabled. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#aapt2 android.enableAapt2=false \ No newline at end of file From 5559e1bb41d13832acb523fa1bb9d74a5d1b811b Mon Sep 17 00:00:00 2001 From: maskara Date: Sat, 4 Nov 2017 15:51:20 +0530 Subject: [PATCH 5/5] Put PR link --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index eeb5ff880..bff1c9f63 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,5 @@ BUTTERKNIFE_VERSION=8.6.0 org.gradle.jvmargs=-Xmx1536M #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 \ No newline at end of file