Intel® Developer Zone offers tools and how-to information for cross-platform app development, platform and technology information, code samples, and peer expertise to help developers innovate and succeed. Join our communities for Android, Internet of Things, Intel® RealSense™ Technology, and Windows to download tools, access dev kits, share ideas with like-minded developers, and participate in hackathon’s, contests, roadshows, and local events.
This document provides step-by-step instructions on how to build SQLCipher for Android on a Linux* host, with architecture settings to an Intel® x86 target.
SQLCipher is an open source extension to SQLite* that provides transparent 256-bit AES encryption of database files. SQLCipher has been adopted as a secure database solution by many commercial and open source products, making it one of the most popular encrypted database platforms for Mobile, Embedded, and Desktop applications.
SQLCipher was developed by Zetetic LLC and initially released in November 2008. At first, SQLCipher was solely used as the security backend for our password manager and data vault, Strip. However, because of its low overhead and compact size, it quickly became popular and is now one of the most heavily used secure database solutions for the platform. In 2011, amid increasing calls for Android support, the Guardian Project and Zetetic jointly released SQLCipher for Android. Along the way, SQLCipher has also been used successfully on other platforms as well, including Windows* C/C++, .NET, Ruby*, Java*, PHP*, Python*, QT*, Mac OS X*, and Linux.
Setting Up in a Linux Environment
Below is the recommended procedure for setting up in a Linux Environment.
Setup and Prerequisites
Before starting, you’ll need to download and install the following:
- Download the Android SDK
- Download the Android NDK
- Download the Java Development Kit (JDK)
The open source SQLCipher for Android can be downloaded from https://www.zetetic.net/sqlcipher/open-source/ URL using the following command:
git clone <a href="https://github.com/sqlcipher/android-database-sqlcipher.git" rel="nofollow">https:
After you get the repository cloned to the local file system, you can move on to the Build Procedure in a Linux Environment section.
The Build Procedure in a Linux Environment
Once you extract the contents to a local directory, say
/home/test/android-database-cipher/
Perform the following steps:
Cd /home/test/android-database-cipher/
~/android-database-cipher> make init
Note: This will take quite a bit of time to clone the required libraries for Android sqlcipher.
The following libraries will be cloned and downloaded as part of sqlcipher external libraries:
- external/sqlcipher
- external/android-sqlite
- external/dalvik
- external/icu4c
- external/openssl
- external/platform-frameworks-base
Perform the following step:
~/android-database-cipher> make
Note: This builds all the libraries for the target architectures mentioned in the Application.mk
file. If the make fails, please refer to the Troubleshooting and Known Issues section at the end of the document.
Intel x86 Android Configuration setting
The architecture configuration can be made similar to that of an Android Project. Make sure you have the following configuration for Intel x86:
Open <project-folder>/jni/Application.mk
Make sure you have the following setting:
APP_ABI := x86
Output Section
Once the build completes successfully, the binaries gets generated in to the following path:
<project-dir>/libs/x86/libdatabase_sqlcipher.so
<project-dir>/libs/x86/libsqlcipher_android.so
<project-dir>/libs/x86/libstlport_shared.so
Troubleshooting and Known Issues
- Issue: Make Failure saying “android update project” fails.
- Resolution: Make sure you have appended the Android tools path to the PATH environment.
- Example:
export PATH=$PATH:~/Android/adtbundle/sdk/tools
export PATH=$PATH:~/Android/adtbundle/sdk/build-tools/android-4.4
- Issue: Make command fails, saying “ndk-build : command not found”
- Resolution: Make sure you have appended the ndk-build path to the PATH environment.
- Example:
export PATH=$PATH:~/Android/android-ndk-r9b
- Issue: If you get an error saying “build.xml not found.”
References
SQLCipher Community Edition:https://www.zetetic.net/sqlcipher/open-source/
Compile SQLite with SQLCipher on Windows: http://stackoverflow.com/questions/4353037/compile-sqlite-with-sqlcipher-on-windows/4399633#4399633
SQLCipher for Android Application Integration: https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
About the Author
Praveen Kundurthy works in the Intel® Software and Services Group. He has a master’s degree in Computer Engineering. His main interests are mobile technologies, Microsoft Windows*, and game development.