SQLite Android Bindings

Check-in [985ad0e6f2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update the installation instructions to reflect the new support for API level 9. And that building the native libraries is now integrated with gradle.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 985ad0e6f280e048aa0bb6103e4690720920efa4
User & Date: dan 2017-04-29 09:24:04.495
Context
2017-05-01
15:14
Define HAVE_USLEEP to avoid 1 second delays when sleep() is called (check-in: efde9e0e44 user: pjw tags: trunk)
2017-04-29
09:24
Update the installation instructions to reflect the new support for API level 9. And that building the native libraries is now integrated with gradle. (check-in: 985ad0e6f2 user: dan tags: trunk)
2017-04-27
18:00
Upgrade this branch to use the enhanced test program from the api-level-9 branch. (check-in: 7275688aed user: dan tags: trunk)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to www/install.wiki.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

  <li> By adding the SQLite Android bindings source code to and building it 
       along with the other application code.
</ol>

<p> By default, the SQLite Android bindings support Android API levels 16 
and greater (Android versions 4.1 and up). There is also a separate version
that supports Android API levels 15 and greater (Android version 4.0.2 and 
up). Please note the extra step involved in [#obtaincode|obtaining the code] 
if you wish to use the version compatible with API level 15.

<h2> <a name=prebuilt></a> 1. Using a Pre-Built aar File</h2>

<p>
  This is the most straightforward option. An "aar" file is similar to a 
  jar file, except that it may contain both compiled java classes and 
  native code. An aar file for the latest SQLite release usable with







|

|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

  <li> By adding the SQLite Android bindings source code to and building it 
       along with the other application code.
</ol>

<p> By default, the SQLite Android bindings support Android API levels 16 
and greater (Android versions 4.1 and up). There is also a separate version
that supports Android API levels 9 and greater (Android version 2.3 and 
up). Please note the extra step involved in [#obtaincode|obtaining the code] 
if you wish to use the version compatible with API level 9.

<h2> <a name=prebuilt></a> 1. Using a Pre-Built aar File</h2>

<p>
  This is the most straightforward option. An "aar" file is similar to a 
  jar file, except that it may contain both compiled java classes and 
  native code. An aar file for the latest SQLite release usable with
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106


























107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
  <p>
  Alternatively, the latest code may be downloaded as a 
  <a href=http://www.sqlite.org/android/zip/SQLite+Android+Bindings.zip?uuid=trunk>zip archive</a>. 
  In this case, the "project directory" is the
  <code>SQLite_Android_Bindings/</code> directory created by unzipping the
  downloaded archive.
  <p>
  <i>API level 15 users:</i> The code for the version that is
  compatible with Android API level 15 may be obtained as a zip
  file 
  <a href=http://www.sqlite.org/android/zip/SQLite+Android+Bindings.zip?uuid=api-level-15>from here</a>.
  Or, if using fossil, the <code>fossil open</code> command above should be
  replaced with: 
  <verbatim>
    $ fossil open ../android.fossil api-level-15</verbatim>

  <li><a name=buildnative></a> <b>Build the native libraries.</b>


























  <p> To build the native libraries, navigate to the
      <code>sqlite3/src/main/</code> directory of the project directory and
      run the <code>ndk-build</code> command. For example, on Linux if 
      Android Studio and the NDK are installed using their default paths:
<verbatim>
    $ cd sqlite3/src/main
    $ ~/Android/Sdk/ndk-bundle/ndk-build</verbatim>
  <p> On modern hardware, this command takes roughly 2 minutes to build the
      native libraries for all Android architectures.
  <p> 
  The latest release of the public domain SQLite library comes bundled 
  with the SQLite Android bindings code downloaded in step 1. If you wish
  to use a different version of SQLite, for example one that contains the
  proprietry [./see.wiki | SEE extension], then replace the <code>sqlite3.c</code>
  and <code>sqlite3.h</code> files at the following locations before running
  the <code>ndk-build</code> command:

<verbatim>
    sqlite3/src/main/jni/sqlite/sqlite3.c
    sqlite3/src/main/jni/sqlite/sqlite3.h</verbatim>
  <p> 
  If you wish to build the SQLite library with non-standard command line
  switches, for example the -DSQLITE_ENABLE_FTS5 switch used to enable 
  <a href=http://www.sqlite.org/fts5.html>FTS5</a>, they should be added to
  the <code>Android.mk</code> file at this location:

<verbatim>
    sqlite3/src/main/jni/sqlite/Android.mk</verbatim>
  <p>
  If the <code>Android.mk</code> or <code>sqlite3.&#91;ch&#93;</code> files
  are edited after <code>ndk-build</code> is run, it may be necessary to run
  the <code>ndk-build clean</code> command before rerunning 
  <code>ndk-build</code> to ensure a correct build.
  <p>
  Once <code>ndk-build</code> has been run successfully, unless you modify
  the <code>Android.mk</code> or <code>sqlite3.&#91;ch&#93;</code> files,
  it should not be necessary to run it again. It <i>does not</i> have to be 
  run each time the application is rebuilt.

  <li> <b>Assemble the aar file</b>. To assemble the aar file using the 
  command line, first set environment variable ANDROID_HOME to the SDK
  directory, then run the gradle "assembleRelease" target from within the
  "sqlite3" sub-directory of the project directory. For example:
<verbatim>
    $ export ANDROID_HOME=~/Android/Sdk/







|
|

|



|

|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|


<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
|
|
<
<
<
<
<







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142














143






144
145





146
147
148
149
150
151
152
  <p>
  Alternatively, the latest code may be downloaded as a 
  <a href=http://www.sqlite.org/android/zip/SQLite+Android+Bindings.zip?uuid=trunk>zip archive</a>. 
  In this case, the "project directory" is the
  <code>SQLite_Android_Bindings/</code> directory created by unzipping the
  downloaded archive.
  <p>
  <i>API level 9-15 users:</i> The code for the version that is
  compatible with Android API level 9 and greater may be obtained as a zip
  file 
  <a href=http://www.sqlite.org/android/zip/SQLite+Android+Bindings.zip?uuid=api-level-9>from here</a>.
  Or, if using fossil, the <code>fossil open</code> command above should be
  replaced with: 
  <verbatim>
    $ fossil open ../android.fossil api-level-9</verbatim>

  <li><a name=buildnative></a> <b>Configure the native libraries.</b>
  <p> 
  The latest release of the public domain SQLite library is bundled 
  with the SQLite Android bindings code downloaded in step 1. If you wish
  to use a different version of SQLite, for example one that contains the
  proprietry [./see.wiki | SEE extension], then replace the <code>sqlite3.c</code>
  and <code>sqlite3.h</code> files at the following locations:
<verbatim>
    sqlite3/src/main/jni/sqlite/sqlite3.c
    sqlite3/src/main/jni/sqlite/sqlite3.h</verbatim>
  <p> 
  By default, SQLite is built with the following options:
<verbatim>
    -DSQLITE_ENABLE_FTS5
    -DSQLITE_ENABLE_RTREE
    -DSQLITE_ENABLE_JSON1
    -DSQLITE_ENABLE_FTS3</verbatim>
  To build the SQLite library with some other combination of command line
  switches, edit the <code>Android.mk</code> file at this location:
<verbatim>
    sqlite3/src/main/jni/sqlite/Android.mk</verbatim>

<li><a name=buildnative2></a> <b>Build the native libraries.</b>
<p>
This step is <b>optional. It will be run automatically by the
</b><code>gradlew</code><b> command in step 4.</b> Running it separately
is primarily useful for for debugging broken builds.
  <p> To build the native libraries, navigate to the
      <code>sqlite3/src/main/</code> directory of the project directory and
      run the <code>ndk-build</code> command. For example, on Linux if 
      Android Studio and the NDK are installed using their default paths:
<verbatim>
    $ cd sqlite3/src/main
    $ ~/Android/Sdk/ndk-bundle/ndk-build</verbatim>
  <p> On modern hardware, this command takes roughly 3 minutes to build the
      native libraries for all Android architectures.
  <p> 














  If the <code>Android.mk</code> file is edited after <code>ndk-build</code> is






  run, it may be necessary to run the <code>ndk-build clean</code> command
  before rerunning <code>ndk-build</code> to ensure a correct build.






  <li> <b>Assemble the aar file</b>. To assemble the aar file using the 
  command line, first set environment variable ANDROID_HOME to the SDK
  directory, then run the gradle "assembleRelease" target from within the
  "sqlite3" sub-directory of the project directory. For example:
<verbatim>
    $ export ANDROID_HOME=~/Android/Sdk/
162
163
164
165
166
167
168





169
170
171
172
173
174
175
  <p>
  Once the custom aar file has been created, it may be used in an Android
  Studio application as described above. The aar file should be roughly
  4.5MB in size. If it is much smaller than this (closer to 100KB), this
  indicates that the aar file is missing the native libraries. The usual
  cause of this is an unnoticed error while building the native libraries 
  (step 2 above).





</ol>

<h2> <a name=directint></a> 3. Adding Source Code Directly to the Application</h2>

<p>
The SQLite Android bindings code may also be added directly to the 
application project, so that it is built and deployed in the same way 







>
>
>
>
>







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
  <p>
  Once the custom aar file has been created, it may be used in an Android
  Studio application as described above. The aar file should be roughly
  4.5MB in size. If it is much smaller than this (closer to 100KB), this
  indicates that the aar file is missing the native libraries. The usual
  cause of this is an unnoticed error while building the native libraries 
  (step 2 above).
  <p>
  If the <code>Android.mk</code> file described in step 2 above is edited 
  after a build has been run, it may be necessary to run the 
  gradle "clean" target (either with <code>../gradlew clean</code> or through
  Android Studio) before rebuilding the aar file to ensure a correct build.
</ol>

<h2> <a name=directint></a> 3. Adding Source Code Directly to the Application</h2>

<p>
The SQLite Android bindings code may also be added directly to the 
application project, so that it is built and deployed in the same way