Android: Sugar ORM No Such Table Exception

后端 未结 21 921
一生所求
一生所求 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条回答
  • 2020-12-05 07:11

    I had the same problem, it's related to Instant Run. Disable instant run, reinstall the application, and it works.

    See this link for details on how to enable or disable Instant Run.

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

    For me the Issue was, In my app I had two different Database. so, I only changed the from version 1 to version 2. My first DB had version 1

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

    Please check this property

        <`meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="trending.hashtags.pojo" />`
    

    This should be exactly where your POJO class is not the package name only.

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

    As stated in the README from the github repo, if you are using proguard, you should ensure that entities remain un-obfuscated so table and columns are named correctly.

    To do so, add this line to proguard-rules.pro:

    -keep class com.yourpackage.yourapp.domainclasspackage.** { *; }
    
    0 讨论(0)
  • 2020-12-05 07:16

    When you're starting initial development and don't want to have to increase your Database version for changes made during quick iterations of your models (something I do a lot while I'm fleshing out unforeseen requirements), use this during your applications start-up:

    SugarDb sugarDb = new SugarDb(getApplicationContext());
    new File(sugarDb.getDB().getPath()).delete();
    Model.findById(Model.class, (long) 1); // Perform this for each SugarRecord  model
    
    // Insert test data:
    Modelrecord = new Model("Model Title", "Model content", false);
    record.save();
    

    Be warned - this will remove all data from your database so persisted changes between debug sessions won't work, however it does allow you to release version 1 of your app version 1 of your database.

    I do not recommend doing this after version 1 has been officially released, make sure you log ALL changes needed using the SugarORM Migration Method.

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

    Make sure the meta data package name points to where you've put your model entities not app package name

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