question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello, i have big problem with Sugar ORM implementation in my project. After hours of searching for working solution, i created new clean project to be sure, that none of another modules don’t break sugar implementation. On new project with only implemented sugar i have still the same error “no such table”. I tried lot of times changing VERSION metadata, extending app class with SugarApp, deleting whole app data, reinstalling app. Instant run is disabled. Problem occurs on Android Studio 1.5 with Gradle Plugin <2 and Android Studio 2.1.1 with Gradle plugin 2.1.0. Here is code of this test project, that generates this error too:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button test = (Button) findViewById(R.id.test);
        test.setOnClickListener(listener);
    }

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                SugarContext.init(getApplicationContext());
                List<Test> testList = new ArrayList<>();
                for (int i = 0; i < 1000; i++) {
                    testList.add(new Test("Name "+i, "Content "+i));
                }
                Test.saveInTx(testList);
                testList = Test.listAll(Test.class);
                Test.deleteInTx(testList);
            } catch (Exception e) {
                e.printStackTrace();
                new AlertDialog.Builder(MainActivity.this).setMessage(e.getMessage()).create().show();
            }
        }
    };

    class Test extends SugarRecord {

        public String name;
        public String content;

        public Test() {
        }

        public Test(String name, String content) {
            this.name = name;
            this.content = content;
        }
    }
}
<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <meta-data android:name="DATABASE" android:value="sugarorm.db" />
        <meta-data android:name="VERSION" android:value="2" />
        <meta-data android:name="QUERY_LOG" android:value="true" />

    </application>

For request i can send zipped project. Thanks in advance

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:26 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
cutikocommented, Jun 1, 2016

Im having the same problem, but only happens with os 5.0 (API level 21) and above. Using Android Studio 2.1.1 and try to downgrade my graddle from 2.1 to 2.0 but still the same problem.

So I was very surprise about this cause this is working in another project no problems at all. The only difference was then the target sdk (maximun)

Momentaneously fix it by lowering the targetSdkVersion to 21 instead of 23

So probably the problem has something to do with the instant run.

I wish with all my heart you can fix this, I have compare with others ORM and sugar is my choice above all, Im very sorry for not being good enough to do a pull request, please fix it.

7reactions
eric-tongcommented, Jun 9, 2016

If nothing else works, you could create the tables manually.

SugarRecord.executeQuery("CREATE TABLE IF NOT EXISTS YOUR_CLASS_NAME (ID INTEGER PRIMARY KEY AUTOINCREMENT, YOUR_COLUMN_NAME TEXT, ANOTHER_COLUMN_NAME INTEGER)");

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - "no such table" exception - Stack Overflow
To fix this error just change "django.contrib.admin" in INSTALLED_APPS to "django.contrib.admin.apps.SimpleAdminConfig" , it will prevent "django.contrib.admin" ...
Read more >
error - no such table - Using Django
I'm trying to make an e-mail authorization and get an error when creating superuser. What's wrong? application 'www' models.py. from django.
Read more >
django.db.utils.OperationalError: no such table abc
OperationalError: no such table: myApp_tableStatus. The table tableStatus exists in my models.py. Any ideas what I can do to fix this ...
Read more >
SQLite 'no such table: json_each' error during notification check
Opened from the Prefect Public Slack Community niko: Hi, we just witnessed an error when running a prefect task locally on a windows...
Read more >
r/flask - sqlalchemy.exc.OperationalError: (sqlite3 ... - Reddit
The error is telling you exactly what the problem is, the table books does not exist. You have declared a model, but never...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found