SiimKinks / sqlitemagic

Compile time processed, annotation driven, no reflection SQLite database layer for Android
https://siimkinks.github.io/sqlitemagic/javadoc/
Apache License 2.0
121 stars 11 forks source link

Sqlite Magic library implementation issue #17

Closed RahamathFern closed 1 month ago

RahamathFern commented 1 month ago

Hi.,

In our project, we have encountered the following issue with your library file in recent days.

> Could not resolve all files for configuration ':classpath'.
   > Could not find com.siimkinks.sqlitemagic:sqlitemagic-plugin:0.23.1.

Project setup: Android Studio 4.1.3, AGP 3.1.4 and Gradle version 4.4

Plugin: image

Class path: image


I'm fixing the issue while using Jitpack (https://jitpack.io/#SiimKinks/sqlitemagic/0.23.0) implementation. After running the app, I'm facing the SQLite magic database initialization error.

Sqlite Initialize:

SqliteMagic.builder(this)
                .sqliteFactory(new FrameworkSQLiteOpenHelperFactory())
                .name("sq_lite_magic.db")
                .openDefaultConnection();

Error:

E: FATAL EXCEPTION: main
    Process: co.nexlabs.fern.dev, PID: 3369
    java.lang.RuntimeException: Unable to create application co.nexlabs.fern.app.App: java.lang.IllegalStateException: Error initializing database. Make sure there is at least one model annotated with @Table
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5463)
        at android.app.ActivityThread.-wrap2(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6176)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
     Caused by: java.lang.IllegalStateException: Error initializing database. Make sure there is at least one model annotated with @Table
        at com.siimkinks.sqlitemagic.SqliteMagic.openConnection(SqliteMagic.java:104)
        at com.siimkinks.sqlitemagic.SqliteMagic$DatabaseSetupBuilder.openDefaultConnection(SqliteMagic.java:215)
        at co.nexlabs.fern.app.App.onCreate(App.java:43)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5460)
        at android.app.ActivityThread.-wrap2(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6176) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 
     Caused by: java.lang.RuntimeException: Looks like SqliteMagic gradle plugin processor did not run. Please make sure that project is configured correctly
        at com.siimkinks.sqlitemagic.SqlUtil.getDbVersion(SqlUtil.java:68)
        at com.siimkinks.sqlitemagic.SqliteMagic.openConnection(SqliteMagic.java:92)
        at com.siimkinks.sqlitemagic.SqliteMagic$DatabaseSetupBuilder.openDefaultConnection(SqliteMagic.java:215) 
        at co.nexlabs.fern.app.App.onCreate(App.java:43) 
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5460) 
        at android.app.ActivityThread.-wrap2(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6176) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 

Could you please let me know any other ways to resolve or initialize the database?

Thanks., Rahamath

SiimKinks commented 1 month ago

Please use the latest lib version and see this example how to setup DB connection: https://github.com/SiimKinks/sqlitemagic/blob/master/sqlitemagic-tests/app/src/main/java/com/siimkinks/sqlitemagic/TestApp.java

rakeshfern commented 1 month ago

why it stopped working suddenly 0.23.1 we have been using this library version in our project very long suddenly from last month we are facing build issue is it must to use the latest lib version?

RahamathFern commented 1 month ago

Hi, I'm using local jar files in version 0.23.1. Why are the generated files not being created and why am I facing a DB initialization issue?

Download the jar files from this url https://artifactory.cronapp.io/libs-snapshot/com/siimkinks/sqlitemagic/sqlitemagic/0.23.1/

image image

Also, I'm encountering an issue with DB initialization from jitpack.io, but the generated files have been created.

rakeshfern commented 1 month ago

We cannot use the latest lib version we need to continue to with 0.23.1 as our project doesn't support androidX,So please help to make this library Version 0.23.1 working why it has stopped to work suddenly from jitpack.io is there any reasons @SiimKinks