Comments (74)
yes, disable instant Run in android studio
from sugar.
Make sure all of your Sugarized classes are located within the same package. I fixed my issue by moving them to a data.sugar package and changing the DOMAIN_PACKAGE_NAME tag in the manifest to be the fully qualified path of that package
from sugar.
I tried above solutions but failed
Finally,Thanks to Allah, i decided to change my class name (it was Mobile, changed to phone) and made version =1 and worked!
from sugar.
Same problem, fixed using gradle 1.5.0 (before was 2.0.0-beta7)
from sugar.
As of 1.2 build, we had a requirement of having a constructor with Context paramter.
With 1.3 beta, we removed that constraint. But we still need the default constructor (i.e.) an empty constructor. In absence of which, the tables fail to get created..
from sugar.
Why is this library so buggy ? Satyan please write some more documentation in the website, in example you have created class without context and in another database creation method there you are passing context, please fix these little issues. BTW , it crashes in my device and also shows a white screen when app starts for 100- 200 ms.
from sugar.
This is not working with GRADLE 2.0.0!!!!!!!
from sugar.
Can you share your model class and the android manifest.. Must be a configuration issue.
thanks,
Satya
from sugar.
This is my manifest:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name="com.orm.SugarApp"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.empresaelectrica.MainActivity"
android:label="Empresa Eléctrica II" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.empresaelectrica.AddAbonado"
android:label="@string/title_activity_add_abonado"
android:parentActivityName="com.example.empresaelectrica.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.empresaelectrica.MainActivity" />
</activity>
<meta-data
android:name="DATABASE"
android:value="abonados.db" />
<meta-data
android:name="VERSION"
android:value="1" />
<meta-data
android:name="QUERY_LOG"
android:value="true" />
<meta-data
android:name="DOMAIN_PACKAGE_NAME"
android:value="com.example" />
</application>
from sugar.
from sugar.
Hi @amaurymuro. I got the same thing, and like you I had included all 4 optional meta-data tags in my manifest. Removing them fixed it for me (and I don't mind having default db name).
@satyan probably one of these that causes the issue? If it helps, my meta-data config was:
<meta-data android:name="DATABASE" android:value="myapp.db" />
<meta-data android:name="VERSION" android:value="1" />
<meta-data android:name="QUERY_LOG" android:value="true" />
<meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.me.myapp.model" />
from sugar.
Happened to me too, but turn out that what was wrong was me not following the Getting Started doc.
I changed the VERSION metadata value to 1, because logically I thought I will be creating the first version of the db at installation, but I was wrong, I guess it was supposed to be used in migration process, so I changed back the value to 2 ( as suggested in the doc ), and it just works.
@satyan , maybe more verbose documentation is necessary here, i.e. in that description of VERSION metadata, just to keep people changing that default value of 2 to 1 initially. Thanks !
from sugar.
guys,
i'm having the same problem...any fixes?
from sugar.
@DidiPc if it's an option for you, try what I did - drop the meta-data tags. One of them is the cause. @awidarto's comment above makes it sound like the problem is the version metadata, so you could start with that.
from sugar.
@DidiPc can you share your manifest and the entity class. Also, try removing the app from the device and running afresh.
If, for some reason, there's an issue with creating table, it would throw this error while performing any db operations.
from sugar.
Hi, I'm had the same problem and I'm resolved by implementing the empty constructor in my SugarRecord subclass.
from sugar.
@ciotto Right. Just checked with my old code, and the only difference was the absence of empty constructor. It's fixed after adding that !
from sugar.
This issue has been resolved. Closing it.
from sugar.
Just to complement anyone how fall on this page, im using Sugar ORM on version 1.3 ... had the same error, removing thie package tag DOMAIN_PACKAGE_NAME solved for me... im still using the other 3.
from sugar.
I am also having a similar problem. If I don't have DOMAIN_PACKAGE_NAME, I get a NullPointerException on my main Activity, if I do have it declared I get the no table error. I have tried with and without the optional attributes but still get those errors. I also have the blank constructor in my model.
(I am using version 1.3)
from sugar.
@bbody how are you import the lib? Using gradle?
In my test im not using gradle, im using eclipse latest with adt latest also! (im not using bundle because bundle has a problem with annotations).
from sugar.
I am using Gradle. I am exploring other libraries at the moment.
from sugar.
@bbody since im not using gradle, cant say that could be a issue to that... don't think so but.
Assure that your classes have an empty constructor as the guys said above.
from sugar.
I have followed all the aforementioned solutions to no avail.
from sugar.
@bbody could you share yours package tags used on android manifest? And one of your classes that extend SugarRecord?
I'm also realized that my android:name="VERSION" android:value="1" isn't 1 (one)!!! Is 2 (two) ... putting 2 on this tag solve another issue i was having...
This must be done even if i install the app from zero!
from sugar.
@bbody i also tried everything suggested without success, in the end i deleted the applications cache and now it works
from sugar.
I'm facing this problem too and the version used is 1.3. I managed to solved it by removing the Constructor of the model class completely, hope it helps someone with similar issue!
from sugar.
where we need to use the constructor
from sugar.
where we need to use the constructor??
from sugar.
this should really be fixed +1
from sugar.
I was having the same issue i solved it by adding
- public empty constructor (Public constructor is must.)
- Increasing the VERSION in manifest file to '20'(can be anything)
from sugar.
Is it possible to Add new table in new version released without removing older version ??
from sugar.
Solved by changing the database name:
<meta-data android:name="DATABASE" android:value="ae_qt_01.db" />
to:
<meta-data android:name="DATABASE" android:value="ae01.db" />
from sugar.
@3ct0m0rph Change DB Name ? Lose Previous Tables And Rows
from sugar.
@HosseinKurd To get it working initially.
from sugar.
@3ct0m0rph So How to add new table to DB witout create new DB file ?
from sugar.
I am using Gradle worked for firs time but next day tried its crashing saying"SQLiteException: no such table _sugar". then after reading all these changed my version from 3 to 5 worked. i don't know why. so i need to change y version daily ? please help
And also I cant down grade the version to below 3
from sugar.
Like the others, i fixed mine with an empty constructor. Just create it in your SugarRecord sub class
from sugar.
Mine works putting the:
# <meta-data android:name="DATABASE" android:value="sugar.db" />
<meta-data android:name="VERSION" android:value="2" />
<meta-data android:name="QUERY_LOG" android:value="true" />
<meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="own.leo.libreria.sqlite" />
outside the "application" tag
Thats weird. The other thing that works for me. Leaving to ="2" the version of database, as the website suggests.
from sugar.
I am getting the same exception and none of the above solutions worked for me
10-09 11:30:21.511 4326-4831/com.example.app E/SQLiteLog: (10) Failed to do file read, got: 0, amt: 100, last Errno: 2
10-09 11:30:26.506 4326-4831/com.example.app E/SQLiteLog: (1) no such table: IMAGE
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:299)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:239)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at java.lang.Thread.run(Thread.java:838)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: Caused by: android.database.sqlite.SQLiteException: no such table: IMAGE (code 1): , while compiling: SELECT * FROM IMAGE
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:886)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:497)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1161)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1032)
10-09 11:30:26.516 4326-4831/com.example.app E/AndroidRuntime: at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1238)
This happens when i add GPU image Android Library. I am using Gradle and Android Studio. Also once i remove GPU image this issue is solved. So i don't know whats the conflict.
I have also posted a question related to this exception on stackoverflow
from sugar.
I have the same issue.
@satyan "But we still need the default constructor (i.e.) an empty constructor. In absence of which, the tables fail to get created.." why? Doesn't java create one by default?
from sugar.
I have a problem when I delete the application file database. Then there is an error android.database.sqlite.SQLiteException: no such table Province, but when I push a database to emulator of all CRUD operations are performed.
Before i was create database table invoking any entity object like
Province province= new Province();
province.save(); - now this cause SQLiteException no such table :|
My entity :
extends SugarRecord
have basic construtor without parameters
Link how look manifest
http://wklej.org/hash/d6732855df6/
from sugar.
@ontur00 which version of sugar are you using? why are you deleting the database file?
from sugar.
compile 'com.github.satyan:sugar:1.3'
Beacuse i trying method which check if( database != exist ) then i want create .db file
from sugar.
try to use 1.4 or master version
from sugar.
I need only change 1.3 to 1.4 and extends SugarRecord - without < T > ?
from sugar.
I have problem manifest
Error:(16, 23) No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher').
from sugar.
do you have a drawable ic_launcher?
from sugar.
I try at new TestProject.
I add
compile 'com.github.satyan:sugar:1.4' - sync project - to gradle
new class at package where is my activity (com.example.user.testsugar1_4 )
in my main activity Book book = new Book("isbn123", "Title here", "2nd edition");
Book.save(); and :
Exception :
Caused by: java.lang.NullPointerException: SugarContext has not been initialized properly. Call SugarContext.init(Context) in your Application.onCreate() method and SugarContext.terminate() in your Application.onTerminate() method.
I use this tutoriall - https://android-arsenal.com/details/1/337
http://pastebin.com/iB1J1KRj - main activity
http://pastebin.com/dgdy7eiX - manifest
http://pastebin.com/jESs2KjQ - gradle
from sugar.
public class TestProjectApp extends Application {
@Override
public void onCreate() {
super.onCreate();
SugarContext.init(this);
}
@Override
public void onTerminate() {
super.onTerminate();
SugarContext.terminate();
}
}
from sugar.
First Thank you very much for help @sibeliusseraphini
I fixed I use a 1.3, I had a mistake in the manifest
meta-data android: name = "DOMAIN_PACKAGE_NAME" android: value = "com.example.user.wrongPackage.Model" - wrong PACKAGE
Advice to other check if you have a well-configured manifest
from sugar.
I just to have the same problem, I fixed by adding an empty contructor, and compile with the 1.3 Sugar orm version and rainstalled the app, and before new testing run cleanner in device and clear cache.
my ManifestFile looks like :
meta-data android:name="DATABASE" android:value="MyDb.db"
meta-data android:name="VERSION" android:value="1"
meta-data android:name="QUERY_LOG" android:value="true" />
meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.example.DemoApp.Models"
Models content a Sugar model classes for example => example extends SugarRecord
from sugar.
For me this error occured because i had Multidex
enabled and i was using a lot of libraries
around 20 of them and it was a very big project with a lot of classes. I debugged and went through the source code and i confirmed it there that the classes that extended sugar record
were never found so in the end i added my classes explicitly
into the source code in order to get my project to work.
I don't know if this would help other but it certainly something that the devs should look into. Try adding the project as library project and try debugging the source code and you will find the same issue.
from sugar.
i did this thing:
change DOMAIN_PACKAGE_NAME = not working
change VERSION = not working
change DATABASE = working
so i think change the db name may help u in this case.
from sugar.
Yes I was having the same issue, @miladna7 Thanks man your suggestion works.
But I wonder why it can't use the same database?
from sugar.
it is fixed on master and on 1.5 version
from sugar.
Hi, no changment, i've got the same error..
from sugar.
@aubertdavy try to change the name of your database or update to the version 1.5
from sugar.
@Gujarats yes that's what i did !!
I upgrated to 1.5, removed my app, changed my db name .. and no changment
from sugar.
Ok i solved my problem extending SugarApp and passing application context (and not base context) on create overriding method
from sugar.
@aubertdavy, can you be more specific?
from sugar.
@cdaringe
Init SugarContext in a derived Application class, passing application base context solved my problem.
from sugar.
public class MySugarApp extends Application {
@OverRide
public void onCreate() {
super.onCreate();
SugarContext.init(getApplicationContext());
}
}
from sugar.
i'm sorry to be a total rookie on this (i rarely code java), but no where in my current app do I use Application
explicitly (perhaps implicitly?). Even if so, I'd like to write some unit tests--I'm unsure how'd I'd get the context otherwise if there'd be no Context
in the test suite.
thanks for the tip.
from sugar.
nm, @aubertdavy, i did figure out how to do that. still gives the error, though, unforunately
Caused by: android.database.sqlite.SQLiteException: no such table: CUSTOMER (code 1): , while compiling: INSERT OR REPLACE INTO CUSTOMER(EMAIL,ID,NAME) VALUES (?,?,?)
from sugar.
try, reinstall the app in the phone, in some cases its necesary, I never use application context to initialize sugar context in my apps
from sugar.
Instant Run now works #564
from sugar.
i have the same problem, but i fixed by:
- Write a subclass extends Application like this:
public class SugarORMApplication extends Application {
@OverRide
public void onCreate() {
super.onCreate();
SugarContext.init(this);
}
@OverRide
public void onTerminate() {
super.onTerminate();
SugarContext.terminate();
}
}
- Add android:name="com.....SugarORMApplication" (to class above) in Manifest file and is fixed
from sugar.
@felipebonezi please check #564
from sugar.
I tried to disable instant run on android studio 2.1.2 but still have no luck.
But actually succeed when using gradle 1.5.0.
classpath 'com.android.tools.build:gradle:1.5.0'
on project's build.gradle.
I hope the patch will be released soon.
from sugar.
This may help :
correct :
<meta-data android:name="DATABASE" android:value="cal.db" />
Error:
<meta-data android:name="DATABASE" android:value="cal_bi.db" />
from sugar.
updating build.gradle to 'com.github.satyan:sugar:1.5' fixed it for me
from sugar.
Not working with kotlin using
'com.github.satyan:sugar:1.5'
from sugar.
I have a problem java.lang.NullPointerException: SugarContext has not been initialized properly. Call SugarContext.init(Context) in your Application.onCreate() method and SugarContext.terminate() in your Application.onTerminate() method.
from sugar.
Related Issues (20)
- Support for user specified ID's being used in the database instead of having them generated automatically.
- Android Studio 3.2.1 DB is no longer created HOT 3
- Is Sugar ORM library affected by the newly found SQLite vulnerability?
- update bug HOT 1
- [QUESTION] Where I can find the CI service?
- OneToMany Annotation
- Missing saveAll() for nested Table
- How read existing DB from assets folder? HOT 1
- Como deletar todos os dados de uma tabela e depois verificar se a tabela está vazia? HOT 1
- No such table with migration HOT 2
- ava.lang.NoSuchMethodException: <init> []
- SugarRecord Read / write separation
- bulk data not inserted completely
- Caused by: android.database.sqlite.SQLiteException: no such table: HOT 5
- *.db file is empty, but in application all the lines are shown.
- RuntimeException on start
- 我使用save来保存数据但是数据当中设置了不可重复字段会对其进行覆盖
- build failed when sync graddle HOT 1
- no such column when select
- Could not resolve project :sugar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sugar.