Sugar.Data and SQlite JDBC Driver on Android App

When running Sugar.Data on Android app, I get this compiler error from the AndroidRuntime:

java.lang.ClassNotFoundException: Didn't find class "org.sqlite.JDBC"

Following the whole stack trace:

01-15 12:30:06.884 1737-1737/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: musixmatch.com.sampleandroidapp, PID: 1737
                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{musixmatch.com.sampleandroidapp/musixmatch.com.sampleandroidapp.MainActivity}: java.lang.ClassNotFoundException: org.sqlite.JDBC
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:148)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                  Caused by: java.lang.ClassNotFoundException: org.sqlite.JDBC
                                                     at java.lang.Class.classForName(Native Method)
                                                     at java.lang.Class.forName(Class.java:324)
                                                     at java.lang.Class.forName(Class.java:285)
                                                     at samplelibrary.SharedClassTest.getDatabaseConnection(/Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Library.swift:79)
                                                     at samplelibrary.SharedClassTest.databaseSetup(/Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Library.swift:113)
                                                     at musixmatch.com.sampleandroidapp.MainActivity.onCreate(MainActivity.java:52)
                                                     at android.app.Activity.performCreate(Activity.java:6251)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:148) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                  Caused by: java.lang.ClassNotFoundException: Didn't find class "org.sqlite.JDBC" on path: DexPathList[[zip file "/data/app/musixmatch.com.sampleandroidapp-1/base.apk"],nativeLibraryDirectories=[/data/app/musixmatch.com.sampleandroidapp-1/lib/arm, /vendor/lib, /system/lib]]
                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                     at java.lang.Class.classForName(Native Method) 
                                                     at java.lang.Class.forName(Class.java:324) 
                                                     at java.lang.Class.forName(Class.java:285) 
                                                     at samplelibrary.SharedClassTest.getDatabaseConnection(/Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Library.swift:79) 
                                                     at samplelibrary.SharedClassTest.databaseSetup(/Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Library.swift:113) 
                                                     at musixmatch.com.sampleandroidapp.MainActivity.onCreate(MainActivity.java:52) 
                                                     at android.app.Activity.performCreate(Activity.java:6251) 
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                     at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:148) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                 	Suppressed: java.lang.ClassNotFoundException: org.sqlite.JDBC
                                                     at java.lang.Class.classForName(Native Method)
                                                     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                     		... 19 more
                                                  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

So, I had to add a jdbc like driver org.xerial:sqlite-jdbc:3.8.11.2 to solve this, but it sounds strange to me i.e. I supposed it only needed the SQlite Android distro package: http://developer.android.com/reference/android/database/sqlite/package-summary.html

Any Sugar.Data method that needs the dependency?

The exact line that caused the BaseDexClassLoader to call java.lang.Class.forName was the following:

let dbConn:SQLiteConnection = SQLiteConnection.init(dbFilePathTop, false, true); // name, readonly, createifneeded

Indeed. That looks like the Cooper version, not the Android version of Sugar.Data. Can you try rebuilding just the Android version and copying out the jar?

Yes I have tried, is it possibile that the license was expired, Fire is warning me about this in the left bar on the project:

Sugar.Data.Cooper.Android - (nolicense)

Odd, it looks like Fire has an issue detecting that Sugar is except form needing an Oxygene license. In any case, you should be able to build Sugar fine — you just want be able to edit the code in Fire. Is that fine for now, for what you need?

Yes exactly, I’m just trying to build the latest fixes to Sugar you did on the development tree, so I 1) have updated to latest commit on develop branch, loaded in Fire, and tried to build, and this caused the license issue. Specifically, this happens on Android target (sugar.jar and sugar.data.jar) not on the iOS one (that are ARMv7 / ARM64), so I was able to update the Sugar.Data bug fix by @ck on the iOS binaries, but not on the Android jars (that I couldn’t build).
Any way to fix this license issue?
Thank you!