SqlCipher problem in Android Studio


#1

I’ve successfully created an app (now in the app store) using SqlCipher as the database. This was done in eclipse. Now, I’ve moved everything over to Android Studio, using the method suggested by the IDE of importing the project directly. Using this method (instead of exporting from eclipse and then importing) the new file structure is automatically put in place, which is great. Everything Nick mentioned in the integration post occurs w/o intervention.

The problem I’m having is with producing a signed APK. Building w/o signing seems to go fine (no errors). However when I attempt to build and generate a signed APK I get this error:

:Project:proguardRelease FAILED
Error:Execution failed for task ‘:Project:proguardRelease’.

java.io.IOException: The same input jar [C:\AndroidStudioImport\Project\libs\sqlcipher.jar] is specified twice.

I’ve checked all the files and folders and I don’t see any spot where sqlcipher is referenced twice. Further, since things work fine with eclipse I’m pretty sure this is an Android Studio problem. But I just want to check with you guys to see if you have any insights on this issue.

Any help is appreciated.

Thanks,

Doug


#2

Hi @Doug

Can you post your full ProGuard file for review?


#3

Here is the proguard information:

To enable ProGuard in your project, edit project.properties

to define the proguard.config property as described in that file.

Add project specific ProGuard rules here.

By default, the flags in this file are appended to flags specified

in ${sdk.dir}/tools/proguard/proguard-android.txt

You can edit the include path and order by changing the ProGuard

include property in project.properties.

For more details, see

http://developer.android.com/guide/developing/tools/proguard.html

Add any project specific keep options here:

Added 03/28/2014 - DP

-keep class android.support.v4.** { *; }   
-dontwarn android.support.v4.**
-keep class android.support.v13.** { *; }
-dontwarn android.support.v13.**
-dontwarn javax.activation.**
-dontwarn javax.security.**
-dontwarn java.awt.**
-dontwarn com.google.common.** 
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe   
-libraryjars <java.home>/lib/rt.jar
-keep,allowobfuscation class com.cetg.project.** {*;}   

-libraryjars android-support-v4.jar

-libraryjars android-support-v13.jar

-libraryjars /libs/sqlcipher.jar
-keep class net.sqlcipher.** {*;}
-dontwarn net.sqlcipher.**
-keep class javax.** {*;}
-keep class com.sun.** {*;}
-keep class myjava.** {*;}
-keep class org.apache.harmony.** {*;}
-keep public class Mail {*;}        

-dontshrink

-dontoptimize    

If your project uses WebView with JS, uncomment the following

and specify the fully qualified class name to the JavaScript interface

class:

#-keepclassmembers class fqcn.of.javascript.interface.for.webview {

public *;

#}


#4

Since I haven’t heard back from anyone I figured I may have replied the wrong way. So I’m putting the proguard information here. Also, since things that have been commented out seems to be enlarged, I’m taking out the comments:

-keep class android.support.v4.** { ; }
-dontwarn android.support.v4.
*
-keep class android.support.v13.** { ; }
-dontwarn android.support.v13.
*
-dontwarn javax.activation.**
-dontwarn javax.security.**
-dontwarn java.awt.**
-dontwarn com.google.common.**
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn sun.misc.Unsafe
-libraryjars <java.home>/lib/rt.jar
-keep,allowobfuscation class com.cetg.project.** {;}
-libraryjars /libs/sqlcipher.jar
-keep class net.sqlcipher.** {
;}
-dontwarn net.sqlcipher.**
-keep class javax.** {;}
-keep class com.sun.** {
;}
-keep class myjava.** {;}
-keep class org.apache.harmony.** {
;}
-keep public class Mail {*;}
-dontoptimize


#5

Hello @Doug

Could you try including the sample provided within the SQLCipher for Android project, modifying it to match any additional requirements you have? I am not seeing what might be causing the duplicate entry in your posting. Barring that, you could try removing the line -libraryjars /libs/sqlcipher.jar to simply see if the behavior changes.


#6

What you suggest is exactly what I did, and the issue with SQLCipher is now gone. Of course, other issues have surfaced, but at least that one is gone. Thanks for your input.

I think the line under dependencies in the build.gradle file and the proguard line are producing the duplicate.

Doug


#7

Hi @Doug

Which suggestion did you try that worked? I’m glad to hear things are working for you now.