From d5b2b9ab7fa423ed974ab59bb2fedb14d88cea4d Mon Sep 17 00:00:00 2001 From: Marco Mirisola Date: Mon, 16 Apr 2018 13:08:31 +0200 Subject: [PATCH 1/8] Updated gradle to latest. --- build.gradle | 8 ++- gradle.properties | 2 + gradle/wrapper/gradle-wrapper.properties | 4 +- gradlew | 78 +++++++++++++---------- gradlew.bat | 16 ++--- library/build.gradle | 21 ++++-- samples/database-v1/build.gradle | 13 ++-- samples/database-v13-upgrade/build.gradle | 22 ++----- samples/database-v2-upgrade/build.gradle | 13 ++-- 9 files changed, 90 insertions(+), 87 deletions(-) diff --git a/build.gradle b/build.gradle index 88e39d0..d85f8d9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,11 @@ buildscript { repositories { - mavenCentral() + jcenter() + google() } dependencies { - classpath "com.android.tools.build:gradle:0.7.+" + classpath 'com.android.tools.build:gradle:3.1.1' } } @@ -13,6 +14,7 @@ allprojects { group = GROUP repositories { - mavenCentral() + google() + jcenter() } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 55c57de..722ee32 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,3 +12,5 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo POM_DEVELOPER_ID=jgilfelt POM_DEVELOPER_NAME=Jeff Gilfelt +org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9b8ffdd..4315ff3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 10 15:27:10 PDT 2013 +#Mon Apr 16 13:02:10 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/gradlew b/gradlew index 91a7e26..6e5d9ef 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,20 +6,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" \ No newline at end of file diff --git a/gradlew.bat b/gradlew.bat index aec9973..0f15bde 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +46,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line @@ -87,4 +81,4 @@ exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega +:omega \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index b8b9d9e..9092940 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,17 +1,23 @@ -apply plugin: 'android-library' +import com.android.builder.core.BuilderConstants +apply plugin: 'com.android.library' android { - buildToolsVersion '19.0.0' - compileSdkVersion 19 + buildToolsVersion '27.0.3' + compileSdkVersion 26 defaultConfig { minSdkVersion 7 } -} + defaultPublishConfig "release" + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_7 + targetCompatibility JavaVersion.VERSION_1_7 + } +} android.libraryVariants.all { variant -> def name = variant.buildType.name - if (name.equals(com.android.builder.BuilderConstants.DEBUG)) { + if (name == BuilderConstants.DEBUG) { return; // Skip debug builds. } def task = project.tasks.create "jar${name.capitalize()}", Jar @@ -19,5 +25,6 @@ android.libraryVariants.all { variant -> task.from variant.javaCompile.destinationDir artifacts.add('archives', task); } - -apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' \ No newline at end of file +apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' +dependencies { +} \ No newline at end of file diff --git a/samples/database-v1/build.gradle b/samples/database-v1/build.gradle index 708c923..429ac78 100644 --- a/samples/database-v1/build.gradle +++ b/samples/database-v1/build.gradle @@ -1,19 +1,18 @@ -apply plugin: 'android' +apply plugin: 'com.android.application' dependencies { - compile project(':library') + implementation project(':library') } android { - buildToolsVersion '19.0.0' - compileSdkVersion 19 + buildToolsVersion '27.0.3' + compileSdkVersion 26 defaultConfig { minSdkVersion 8 - packageName 'com.example.sqliteassethelper' - targetSdkVersion 19 + applicationId 'com.example.sqliteassethelper' + targetSdkVersion 26 versionCode 1 versionName '1.0' } - } \ No newline at end of file diff --git a/samples/database-v13-upgrade/build.gradle b/samples/database-v13-upgrade/build.gradle index 131d755..32b40d4 100644 --- a/samples/database-v13-upgrade/build.gradle +++ b/samples/database-v13-upgrade/build.gradle @@ -1,35 +1,27 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:0.7.+' - } -} -apply plugin: 'android' +apply plugin: 'com.android.application' repositories { mavenCentral() } android { - compileSdkVersion 19 - buildToolsVersion "19.0.0" + compileSdkVersion 26 + buildToolsVersion '27.0.3' defaultConfig { minSdkVersion 8 - targetSdkVersion 19 + targetSdkVersion 26 versionCode 3 versionName "3.0" } buildTypes { release { - runProguard false + minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { - compile project(':library') -} + implementation project(':library') +} \ No newline at end of file diff --git a/samples/database-v2-upgrade/build.gradle b/samples/database-v2-upgrade/build.gradle index 2be5d87..a05ff43 100644 --- a/samples/database-v2-upgrade/build.gradle +++ b/samples/database-v2-upgrade/build.gradle @@ -1,19 +1,18 @@ -apply plugin: 'android' +apply plugin: 'com.android.application' dependencies { - compile project(':library') + implementation project(':library') } android { - buildToolsVersion '19.0.0' - compileSdkVersion 19 + buildToolsVersion '27.0.3' + compileSdkVersion 26 defaultConfig { minSdkVersion 8 - packageName 'com.example.sqliteassethelper' - targetSdkVersion 19 + applicationId 'com.example.sqliteassethelper' + targetSdkVersion 26 versionCode 2 versionName '2.0' } - } \ No newline at end of file From a831cc084f5a8b3485b94e7770870030c9ef1ad9 Mon Sep 17 00:00:00 2001 From: Marco Mirisola Date: Mon, 16 Apr 2018 13:08:42 +0200 Subject: [PATCH 2/8] Fixed DB leaks --- .../readystatesoftware/sqliteasset/SQLiteAssetHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java index ebee1c9..192e13e 100755 --- a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java +++ b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java @@ -179,6 +179,7 @@ public synchronized SQLiteDatabase getWritableDatabase() { // do force upgrade if (version != 0 && version < mForcedUpgradeVersion) { + db.close(); db = createOrOpenDatabase(true); db.setVersion(mNewVersion); version = db.getVersion(); @@ -288,6 +289,7 @@ public synchronized void close() { mDatabase.close(); mDatabase = null; } + super.close(); } @Override @@ -391,6 +393,7 @@ private SQLiteDatabase createOrOpenDatabase(boolean force) throws SQLiteAssetExc // database already exists if (force) { Log.w(TAG, "forcing database upgrade!"); + db.close(); copyDatabaseFromAssets(); db = returnDatabase(); } @@ -513,4 +516,4 @@ public SQLiteAssetException(String error) { } } -} +} \ No newline at end of file From 3c1f600ab130a0c9a18d06713d93c38e7bf6e8cc Mon Sep 17 00:00:00 2001 From: Marco Mirisola Date: Mon, 16 Apr 2018 14:23:35 +0200 Subject: [PATCH 3/8] jitpack configuration --- build.gradle | 1 + library/build.gradle | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d85f8d9..3436450 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.1.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' } } diff --git a/library/build.gradle b/library/build.gradle index 9092940..4c6ffb6 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,6 +1,8 @@ import com.android.builder.core.BuilderConstants apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' + android { buildToolsVersion '27.0.3' compileSdkVersion 26 @@ -25,6 +27,6 @@ android.libraryVariants.all { variant -> task.from variant.javaCompile.destinationDir artifacts.add('archives', task); } -apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle' + dependencies { } \ No newline at end of file From 8b2d453d3ee2358f3e207e92a0279c5dc3fd9635 Mon Sep 17 00:00:00 2001 From: Marco Mirisola Date: Mon, 16 Apr 2018 16:17:10 +0200 Subject: [PATCH 4/8] Increase the buffer size from 1024 to 4096 --- .../src/main/java/com/readystatesoftware/sqliteasset/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/readystatesoftware/sqliteasset/Utils.java b/library/src/main/java/com/readystatesoftware/sqliteasset/Utils.java index 67cecaf..fb63656 100644 --- a/library/src/main/java/com/readystatesoftware/sqliteasset/Utils.java +++ b/library/src/main/java/com/readystatesoftware/sqliteasset/Utils.java @@ -40,7 +40,7 @@ public static List splitSqlScript(String script, char delim) { } public static void writeExtractedFileToDisk(InputStream in, OutputStream outs) throws IOException { - byte[] buffer = new byte[1024]; + byte[] buffer = new byte[4096]; int length; while ((length = in.read(buffer))>0){ outs.write(buffer, 0, length); From b3775ee33aac11a8abb3bcf032d93a4b1b02dd78 Mon Sep 17 00:00:00 2001 From: Tim Kist Date: Fri, 10 Sep 2021 15:08:43 +0100 Subject: [PATCH 5/8] Remove unsupported plugin for Gradle 7.0.0 --- library/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/library/build.gradle b/library/build.gradle index 4c6ffb6..453a82c 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,7 +1,6 @@ import com.android.builder.core.BuilderConstants apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' android { buildToolsVersion '27.0.3' From c4846456b9d163079f262929738dfe4412bc2345 Mon Sep 17 00:00:00 2001 From: Tim Kist Date: Fri, 10 Sep 2021 15:09:52 +0100 Subject: [PATCH 6/8] Disable write-ahead logging when force-opening database to check presence --- .../com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java index 192e13e..87a4838 100755 --- a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java +++ b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java @@ -179,6 +179,7 @@ public synchronized SQLiteDatabase getWritableDatabase() { // do force upgrade if (version != 0 && version < mForcedUpgradeVersion) { + db.disableWriteAheadLogging(); db.close(); db = createOrOpenDatabase(true); db.setVersion(mNewVersion); From 4173e91e53808b707b86d82b8a429fed3c609f3a Mon Sep 17 00:00:00 2001 From: Tim Kist Date: Fri, 10 Sep 2021 15:46:26 +0100 Subject: [PATCH 7/8] Increase minSdkVersion to 16 --- library/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/build.gradle b/library/build.gradle index 453a82c..1872d26 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -7,7 +7,7 @@ android { compileSdkVersion 26 defaultConfig { - minSdkVersion 7 + minSdkVersion 16 } defaultPublishConfig "release" From ca67a06e99d8c75acd64ffadeb66891b09b33b8e Mon Sep 17 00:00:00 2001 From: Tim Kist Date: Thu, 23 Sep 2021 15:43:34 +0100 Subject: [PATCH 8/8] Disable write-ahead logging for all open database calls --- .../com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java index 87a4838..31d5c5a 100755 --- a/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java +++ b/library/src/main/java/com/readystatesoftware/sqliteasset/SQLiteAssetHelper.java @@ -264,6 +264,7 @@ public synchronized SQLiteDatabase getReadableDatabase() { mIsInitializing = true; String path = mContext.getDatabasePath(mName).getPath(); db = SQLiteDatabase.openDatabase(path, mFactory, SQLiteDatabase.OPEN_READONLY); + db.disableWriteAheadLogging(); if (db.getVersion() != mNewVersion) { throw new SQLiteException("Can't upgrade read-only database from version " + db.getVersion() + " to " + mNewVersion + ": " + path); @@ -411,6 +412,7 @@ private SQLiteDatabase returnDatabase(){ try { SQLiteDatabase db = SQLiteDatabase.openDatabase(mDatabasePath + "/" + mName, mFactory, SQLiteDatabase.OPEN_READWRITE); Log.i(TAG, "successfully opened database " + mName); + db.disableWriteAheadLogging(); return db; } catch (SQLiteException e) { Log.w(TAG, "could not open database " + mName + " - " + e.getMessage());