I have been looking for a solution to my problem for a long time, and I just want to share my solution with others who may have the same problem.
I came from the Eclipse IDE while developing an Android application, and I wanted to check out the Android Studio IDE. So I downloaded the current Android studio (BETA v0.8.6), and still I really like what they do with Android Studio.
My problem: I used the SQLCipher libraries to include an encrypted database in my project. Unfortunately, the integration of SQLCipher in Android Studio does not work, as they say on the official site of SQLCipher (since the manual is written for the Eclipse IDE). Therefore, I searched the Internet for a solution to integrate SQLCipher into Android Studio, because I could not import it into my main java activity class.
My solution: You download the SQLCipher assembly from the official site. In this folder you will see two folders. The assets folder and the libs folder.
The "libs" folder contains your * .jar files and some folders for each supported architecture with some * .so files inside them.
Now you do the following:
- Go to the project folder (standard in: C: \ Users \\ AndroidStudioProjects \)
- Open the app folder
- Copy the three .jar files (commons-codec, guava-r09, sqlcipher) into the "lib" folder.
- Now go to: app \ src \ main and create two folders: "assets" and "jniLibs".
- Copy the icudt46l.zip file to the "assets" folder.
- Copy the "armeabi", "armeabi-v7a" and "x86" folders to the "jniLibs" folder.
Now launch Android Studio and open your project. In Android Studio you see the files in the form of a tree on the left.
- Expand the “application” folder with Android Studio so that you can see the “build.gradle” file.
- Open the build.gradle file.
Now in the grade.build file, make sure that this piece of code is included at the bottom of the file:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }
Now it should look something like this:
apply plugin: 'com.android.application' android { compileSdkVersion 'android-L' buildToolsVersion "20.0.0" defaultConfig { applicationId "com.example.testapp" minSdkVersion 15 targetSdkVersion 'L' versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) }
Finally, importing SQLCipher should now work. It is important that you create the jniLibs folder with that name! Otherwise it will not work.
I also wanted to add photos, but I don’t have any credit points yet. As soon as I have, I will add photos that I took to this post.
Greetz, Steffen
Spyro source share