reader/android: make it easier to use the local version of android-lib
Recently, there were a few cases where I spent much time debugging
something that has been fixed in the latest go code but not yet
reflected in the published version of io.v:vanadium-android library.
This CL updates the Reader app gradle script so that it can be easily
built with the local version of vanadium-android library by passing
"-DuseLocalVanadiumLib" to the gradle command.
This also updates the vanadium-android library to v0.5, and conforms
to the API changes.
Change-Id: I33ff2756f2b12dd1a45f1114b7f2d00429aa51ec
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 7d4314b..bb46007 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -42,8 +42,8 @@
}
android {
- compileSdkVersion 22
- buildToolsVersion "22.0.1"
+ compileSdkVersion 23
+ buildToolsVersion "23.0.1"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
@@ -52,8 +52,8 @@
defaultConfig {
applicationId "io.v.android.apps.reader"
- minSdkVersion 22
- targetSdkVersion 22
+ minSdkVersion 23
+ targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
@@ -82,14 +82,30 @@
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:design:22.2.1'
- compile 'com.android.support:appcompat-v7:22.2.1'
- compile 'com.android.support:cardview-v7:22.2.1'
- compile 'com.android.support:recyclerview-v7:22.2.1'
- compile 'io.v:vanadium-android:0.3'
+ compile 'com.android.support:design:23.0.1'
+ compile 'com.android.support:appcompat-v7:23.0.1'
+ compile 'com.android.support:cardview-v7:23.0.1'
+ 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'
- compile 'io.v:baku-toolkit:0.3.0'
+
+ // 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'
+ }
+
+ // Required by baku-toolkit.
apk ('org.slf4j:slf4j-android:1.7.13')
}
diff --git a/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java b/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
index ca197d0..2fe4b6e 100644
--- a/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
+++ b/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
@@ -502,7 +502,7 @@
// TODO(youngseokyoon): check if the same blob is already in the database.
try {
BlobWriter writer = sync(mLocalSB.db.writeBlob(mVContext, null));
- OutputStream out = sync(writer.stream(mVContext));
+ OutputStream out = writer.stream(mVContext);
out.write(bytes);
out.close();
@@ -532,7 +532,7 @@
try {
BlobReader reader = mLocalSB.db.readBlob(mVContext, file.getRef());
- return ByteStreams.toByteArray(sync(reader.stream(mVContext, 0L)));
+ return ByteStreams.toByteArray(reader.stream(mVContext, 0L));
} catch (VException | IOException e) {
handleError("Could not read the blob " + file.getRef().toString()
+ ": " + e.getMessage());
@@ -650,8 +650,8 @@
// Read existing data from the table.
Table table = batch.getTable(mTableName);
- VIterable<KeyValue> kvs = InputChannels.asIterable(sync(table.scan(
- mCancelableVContext, RowRange.range("", ""))));
+ VIterable<KeyValue> kvs = InputChannels.asIterable(
+ table.scan(mCancelableVContext, RowRange.range("", "")));
for (KeyValue kv : kvs) {
@SuppressWarnings("unchecked")
E item = (E) VomUtil.decode(kv.getValue(), mClass);
@@ -672,8 +672,8 @@
private void watchForChanges() {
try {
// Watch for new changes coming from other Syncbase peers.
- VIterable<WatchChange> watchStream = InputChannels.asIterable(sync(
- mLocalSB.db.watch(mCancelableVContext, mTableName, "", mResumeMarker)));
+ VIterable<WatchChange> watchStream = InputChannels.asIterable(
+ mLocalSB.db.watch(mCancelableVContext, mTableName, "", mResumeMarker));
Log.i(TAG, "Watching for changes of table: " + mTableName + "...");
diff --git a/android/settings.gradle b/android/settings.gradle
index e7b4def..40ea8da 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1 +1,8 @@
include ':app'
+
+if (System.getProperty('useLocalVanadiumLib') != null) {
+ include ':lib', ':android-lib'
+
+ project(':lib').projectDir = new File(settingsDir, '../../../java/lib')
+ project(':android-lib').projectDir = new File(settingsDir, '../../../java/android-lib')
+}