reader/android: fix the problem with libv23.so when using local android-lib
Now the script uses dependencySubstitution clause to subsitute the
'io.v:vanadium-android' module with ':android-lib' project, even when
the module appears in the transitive dependency graph.
This requires gradle 2.5 or higher, so gradle wrapper is also updated.
Change-Id: I71b2d624f03789683ed4415cc0cc9f8d18a3d60c
diff --git a/android/app/.gitignore b/android/app/.gitignore
index 57d76e1..73eb7fe 100644
--- a/android/app/.gitignore
+++ b/android/app/.gitignore
@@ -1,3 +1,4 @@
/build
google-services.json
+/src/main/jniLibs
diff --git a/android/app/build.gradle b/android/app/build.gradle
index bb46007..d683530 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -52,7 +52,7 @@
defaultConfig {
applicationId "io.v.android.apps.reader"
- minSdkVersion 23
+ minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
@@ -88,22 +88,8 @@
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.google.android.gms:play-services-analytics:8.3.0'
compile 'org.apache.commons:commons-csv:1.2'
-
- // To use the local version of vanadium-android library,
- // use "-DuseLocalVanadiumLib" parameter in the gradle command.
- if (System.getProperty('useLocalVanadiumLib') != null) {
- compile project(':android-lib')
-
- // Since baku-toolkit has a transitive dependency on the public version of vanadium-android
- // library, it should be explicitly excluded.
- compile('io.v:baku-toolkit:0.3.0') {
- exclude module: 'vanadium-android'
- exclude group: 'io.v'
- }
- } else {
- compile 'io.v:vanadium-android:0.5'
- compile 'io.v:baku-toolkit:0.3.0'
- }
+ compile 'io.v:vanadium-android:0.5'
+ compile 'io.v:baku-toolkit:0.3.0'
// Required by baku-toolkit.
apk ('org.slf4j:slf4j-android:1.7.13')
@@ -130,3 +116,35 @@
// These two tasks should run before 'preBuild' task
tasks['preBuild'].dependsOn('copyPdfJsFiles')
+
+
+// To use the local version of vanadium-android library,
+// use "-DuseLocalVanadiumLib" parameter in the gradle command.
+if (System.getProperty('useLocalVanadiumLib') != null) {
+
+ // NOTE: Make sure that the gradle wrapper version is 2.5 or higher, before using the dependency
+ // substitution feature.
+ configurations.all {
+ resolutionStrategy {
+ dependencySubstitution {
+ substitute module('io.v:vanadium-android') with project(':android-lib')
+ }
+ }
+ }
+
+ // Copy the Vanadium native library to the correct location.
+ def jiriRoot = new File(projectDir, '../../../../..').canonicalPath
+ task copyVanadiumLib(type: Copy, dependsOn: ':android-lib:goBuildVanadiumLib') {
+ logger.info(jiriRoot + '/release/go/pkg/android_arm_shared_shared/v.io/x/jni')
+ from jiriRoot + '/release/go/pkg/android_arm_shared_shared/v.io/x/jni'
+ into 'src/main/jniLibs/armeabi-v7a'
+ include 'main.a'
+ rename 'main.a', 'libv23.so'
+ }
+
+ tasks['preBuild'].dependsOn('copyVanadiumLib')
+}
+
+clean {
+ delete 'src/main/jniLibs/armeabi-v7a/libv23.so'
+}
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
index 8c0fb64..30d399d 100644
--- a/android/gradle/wrapper/gradle-wrapper.jar
+++ b/android/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 7c6e9cb..69181f0 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Sep 30 17:13:07 PDT 2015
+#Wed Dec 09 11:29:06 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-bin.zip