Recently I need to use sqlite3 to quickly modify values in a db file located in an android device. Usually the easy way is to directly copy an sqlite3 ELF file from an exist AOSP rom’s side products of target architecture, but sometimes we may not have any aosp rom built on our disk or even no aosp source files on disk. So it may be not convenience to archive a executable sqlite3 ELF file from a built rom’s side products. So it will be fine to build sqlite3 from sqlite3 source file directly. This article will tell you how to build a usable sqlite3 from sqlite’s source file via android-ndk.
I Assume you are using Linux.
- ANDROID NDK: Because we are going to build ELF file for android, so you must have Android-NDK installed. If you don’t have it, install it via distribution’s package manager(If you are using Linux) or directly download from official site.
- The Source File: Then we should download the source file of sqlite. The source file can be downloaded easily from its Official Site.
- Essential Building Components: Also make sure your system has essential building components installed. If it alerts any missing when building, just install them.
Now everything is ok. We can start our building action. To avoid any not errors when building. Here I recommend you use the Standalone ToolChain.
A standalone toolchain can be easily setup via do what the tutorial says.
# Create an arm64 API 26 libc++ toolchain.
Now everything is ok. Extract the source file to some place you want, then use configure and make like below shows, the sqlite ELF file will be generated successfully.
$tar -xzvf sqlite-snapshot-201807272333.tar.gz