Android: Sugar ORM No Such Table Exception

后端 未结 21 923
一生所求
一生所求 2020-12-05 06:42

I am getting the No Such table exception when i am Using Sugar ORM with GPU image Android Library. I am using Gradle and Android Studio. Once i remove GPU image

相关标签:
21条回答
  • If you add new model(new table) in your code, you need change version of database in Manifest file. New value > Old value (update)

     <meta-data
                android:name="VERSION"
                android:value="1"/>
    
    0 讨论(0)
  • 2020-12-05 07:02

    I was also having this issue, my class only had 1 String property. I was using version 1.3. Just comment this code from AndroidManifest.xml file and you're good to go :)

    <meta-data
     android:name="DOMAIN_PACKAGE_NAME"
     android:value="com.project.database.entities" />
    

    Reference:

    https://github.com/satyan/sugar/issues/75

    0 讨论(0)
  • 2020-12-05 07:05

    In my case, I removed the following line from AndroidManifest.xml and it works!

    0 讨论(0)
  • 2020-12-05 07:07

    I am using version 1.5 and have tried many ways here but not work.

    And I found the solution!

    This will force to create tables when starting the app:

    public class SugarOrmTestApplication extends SugarApp {
        @Override
        public void onCreate() {
            super.onCreate();
            SugarContext.init(getApplicationContext());
    
            // create table if not exists
            SchemaGenerator schemaGenerator = new SchemaGenerator(this);
            schemaGenerator.createDatabase(new SugarDb(this).getDB());
        }
    
        @Override
        public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
        }
    
        @Override
        public void onLowMemory() {
            super.onLowMemory();
        }
    
        @Override
        public void onTerminate() {
            super.onTerminate();
            SugarContext.terminate();
        }
    }
    
    0 讨论(0)
  • 2020-12-05 07:10

    I also faced this Problem. After hunted 2 days, I solved it by following tricks In android studio

    Step 1. Write compile 'com.github.satyan:sugar:1.5' in dependencies in build.gradle file of app

    Step 2. Write classpath 'com.android.tools.build:gradle:2.1.0' in dependencies of build.gradle file of project

    Step 3. DB version should greater than 1 always as documented in sugarORM

    0 讨论(0)
  • 2020-12-05 07:10

    Did you try to change version to 2??? This could be different version, try other values as well.

    Also, make sure you do have empty constructor on your SugarRecord classes.

    Change de database name if you are using then is another approuche.

    If you are creating the table without unistalling the app, please make the version number +1.

    0 讨论(0)
提交回复
热议问题