I'm having this error with my sqlite code but I don't know what to make of it because I am a beginner. Here is my logcat, any help would be appreciated. I can paste more code if you want.
My application just adds a contact to a database.
09-28 06:21:51.772: E/SQLiteLog(1564): (1) near "number": syntax error
09-28 06:21:51.803: E/SQLiteDatabase(1564): Error inserting mobile number=1233456 work address= home number=7658678 home address=123 Fake Street first name=John email address=jsmith#gmail.com last name=Smith work number=54372 notes=
09-28 06:21:51.803: E/SQLiteDatabase(1564): android.database.sqlite.SQLiteException: near "number": syntax error (code 1): , while compiling: INSERT INTO contacts(mobile number,work address,home number,home address,first name,email address,last name,work number,notes) VALUES (?,?,?,?,?,?,?,?,?)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at com.example.contactmanager.DatabaseHandler.addContact(DatabaseHandler.java:80)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at com.example.contactmanager.NewContactActivity$1.onClick(NewContactActivity.java:63)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.view.View.performClick(View.java:4240)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.view.View$PerformClick.run(View.java:17721)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.os.Handler.handleCallback(Handler.java:730)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.os.Looper.loop(Looper.java:137)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at java.lang.reflect.Method.invoke(Method.java:525)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-28 06:21:51.803: E/SQLiteDatabase(1564): at dalvik.system.NativeStart.main(Native Method)
I'm not looking for a very specific answer I just want to know where I should be looking to fix this problem. Thanks
EDIT: I put the underscores but now the error is saying there is no home address column in table contacts.
instead of mobile number its better if you give your field name as mobile_number (don't give the space). There might be possibilities where mobile and number can be considered as two separate fields.
Related
I have a full fledged app ...I renamed its package name ... and tried to run but after displaying the first page it get crashed..
here is my logcat:
815-2815/com.Bubbles E/SQLiteLog﹕ (1) no such table: centers
08-06 14:12:22.164 2815-2815/com.Bubbles D/AndroidRuntime﹕ Shutting down VM
08-06 14:12:22.165 2815-2815/com.Bubbles E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.Bubbles, PID: 2815
android.database.sqlite.SQLiteException: no such table: centers (code 1): , while compiling: SELECT * FROM centers where centername='Delhi'
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1255)
at com.Bubbles.database.DataBaseHelper.getCityCode(DataBaseHelper.java:413)
at com.Bubbles.Login.GetCityCode(Login.java:233)
at com.Bubbles.Login.Insertvalues(Login.java:175)
at com.Bubbles.Login.access$400(Login.java:26)
at com.Bubbles.Login$3.onClick(Login.java:144)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
waiting for a help..thanks in advance
You did more things than package rename as the real cause is:
android.database.sqlite.SQLiteException: no such table: centers
It started on an Android phone, simple create statement in a file inside the assets/migrations folder (I use a 3rd party library called ActiveAndroid and for 2 years it worked okay - I did not changed anything about that):
CREATE TABLE IF NOT EXISTS Car (Brand TEXT);
I get this exception:
04-07 15:31:36.683 15738-15738/? E/SQLiteLog﹕ (21) API called with NULL prepared statement
04-07 15:31:36.683 15738-15738/? E/SQLiteLog﹕ (21) misuse at line 63243 of [00bb9c9ce4]
java.lang.RuntimeException: Unable to create application com.activeandroid.app.Application: android.database.sqlite.SQLiteException: not an error (code 0)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4394)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: not an error (code 0)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:727)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1665)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
at com.activeandroid.DatabaseHelper.executeSqlScript(DatabaseHelper.java:185)
at com.activeandroid.DatabaseHelper.executeMigrations(DatabaseHelper.java:155)
at com.activeandroid.DatabaseHelper.onUpgrade(DatabaseHelper.java:78)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:257)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.activeandroid.Cache.openDatabase(Cache.java:104)
at com.activeandroid.Cache.initialize(Cache.java:77)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:43)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:30)
at com.activeandroid.app.Application.onCreate(Application.java:25)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4391)
at android.app.ActivityThread.access$1300(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
So I checked it on my computer with a Firefox addon called SQLite Manager and created a brand new file (the file is totally unrelated to the Android database).
I used this select and on the last error I get this:
It seems that every SQLite statement is a not an error statement.
Unfortunately, Android can't handle that.
What should I do?
It seems that the upgrade script in the assets\migration folder had some empty lines and that caused the not an error.
My android app runs fine, ads appear and work correctly etc, on the emulator and when I test it on phones using eclipse adt, but when it's downloaded from the play store it crashes immediately giving the logcat output:
09-28 18:50:21.280: E/AndroidRuntime(17895): FATAL EXCEPTION: main
09-28 18:50:21.280: E/AndroidRuntime(17895): Process: com.jakebarnby.pop, PID: 17895
09-28 18:50:21.280: E/AndroidRuntime(17895): java.lang.AssertionError
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.b.a.bf.<init>(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.b.a.as.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.j.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.b.a.q.<init>(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.b.a.p.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.b.a.p.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.b.a.p.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.j.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.j.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.j.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.j.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.i.j.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.o.b(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.o.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.startapp.android.publish.o.a(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at jakebarnby.pop.MainActivity.onCreate(Unknown Source)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.Activity.performCreate(Activity.java:5312)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2181)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2276)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.ActivityThread.access$800(ActivityThread.java:144)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.os.Handler.dispatchMessage(Handler.java:102)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.os.Looper.loop(Looper.java:136)
09-28 18:50:21.280: E/AndroidRuntime(17895): at android.app.ActivityThread.main(ActivityThread.java:5146)
09-28 18:50:21.280: E/AndroidRuntime(17895): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 18:50:21.280: E/AndroidRuntime(17895): at java.lang.reflect.Method.invoke(Method.java:515)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
09-28 18:50:21.280: E/AndroidRuntime(17895): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
09-28 18:50:21.280: E/AndroidRuntime(17895): at dalvik.system.NativeStart.main(Native Method)
and I have no idea why. Any help would be greatly appreciated
Does your proguard enabled? If it is, you have to add obfustication code of startapp. It is written their documentation. Here is the link. And codes are copied from there.
-keep class com.startapp.** {
*;
}
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile,
LineNumberTable, *Annotation*, EnclosingMethod
-dontwarn android.webkit.JavascriptInterface
-dontwarn com.startapp.**
I am running 4 background tasks in a activity. But I was getting an error in one activity at
pDialog.show(). I am unable understand the. For some activities I got the same problem but I removed the progress dialog because those are medium priority but this one I need High priority. Here is my error. Can any tell me how to solve this error.
09-28 19:44:53.575: I/Choreographer(1120): Skipped 86 frames! The application may be doing too much work on its main thread.
09-28 19:44:54.374: E/WindowManager(1120): Activity com.example.newairways.Gscan has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{40d40860 V.E..... R.....ID 0,0-684,192} that was originally added here
09-28 19:44:54.374: E/WindowManager(1120): android.view.WindowLeaked: Activity com.example.newairways.Gscan has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{40d40860 V.E..... R.....ID 0,0-684,192} that was originally added here
09-28 19:44:54.374: E/WindowManager(1120): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:354)
09-28 19:44:54.374: E/WindowManager(1120): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:216)
09-28 19:44:54.374: E/WindowManager(1120): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
09-28 19:44:54.374: E/WindowManager(1120): at android.app.Dialog.show(Dialog.java:281)
09-28 19:44:54.374: E/WindowManager(1120): at com.example.newairways.Gscan$insert.onPreExecute(Gscan.java:304)
09-28 19:44:54.374: E/WindowManager(1120): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
09-28 19:44:54.374: E/WindowManager(1120): at android.os.AsyncTask.execute(AsyncTask.java:534)
09-28 19:44:54.374: E/WindowManager(1120): at com.example.newairways.Gscan$1.onClick(Gscan.java:201)
09-28 19:44:54.374: E/WindowManager(1120): at android.view.View.performClick(View.java:4204)
09-28 19:44:54.374: E/WindowManager(1120): at android.view.View$PerformClick.run(View.java:17355)
09-28 19:44:54.374: E/WindowManager(1120): at android.os.Handler.handleCallback(Handler.java:725)
09-28 19:44:54.374: E/WindowManager(1120): at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 19:44:54.374: E/WindowManager(1120): at android.os.Looper.loop(Looper.java:137)
09-28 19:44:54.374: E/WindowManager(1120): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-28 19:44:54.374: E/WindowManager(1120): at java.lang.reflect.Method.invokeNative(Native Method)
09-28 19:44:54.374: E/WindowManager(1120): at java.lang.reflect.Method.invoke(Method.java:511)
09-28 19:44:54.374: E/WindowManager(1120): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-28 19:44:54.374: E/WindowManager(1120): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-28 19:44:54.374: E/WindowManager(1120): at dalvik.system.NativeStart.main(Native Method)
09-28 19:44:57.234: E/Trace(1146): error opening trace file: No such file or directory (2)
Use a Handler to show dialog if you are using AsyncTask or Thread in your program. And if the problem still exists, please try posting your code for further help :)
All progress dialogs should be closed before exiting an activity.
You have probably forgotten to close your progressDialog.
Close it in your onPostExecute() method
pDialog.dismiss();
Check out this SO link for more clarifation on windowleaked error.
Only few users are having the following error, I really don't know where to look for this error as the sql database file is at right position, the sql manager open it and then don't find a table that is there !!
I noted that this happened just when using the CursorLoader of support V4 library, probably the error is inside that code ?
Any suggestion or answer will be helpfully.
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.support.v4.b.r.done(SourceFile:137)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)Caused by: android.database.sqlite.SQLiteException: no such table: records: , while compiling: SELECT _id, name, isbackground FROM records ORDER BY _id ASC
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:127)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:53)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1564)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:354)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:291)
at com.voicepro.db.RecordsContentProvider.query(SourceFile:289)
at android.content.ContentProvider$Transport.query(ContentProvider.java:178)
at android.content.ContentResolver.query(ContentResolver.java:311)
at android.support.v4.b.f.loadInBackground(SourceFile:49)
at android.support.v4.b.f.loadInBackground(SourceFile:35)
at android.support.v4.b.a.onLoadInBackground(SourceFile:240)
at android.support.v4.b.b.doInBackground(SourceFile:51)
at android.support.v4.b.b.doInBackground(SourceFile:40)
at android.support.v4.b.q.call(SourceFile:123)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) android.database.sqlite.SQLiteException: no such table: records: , while compiling: SELECT _id, name, isbackground FROM records ORDER BY _id ASC
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:68)
at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143)
at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:127)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:94)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:53)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1564)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:354)
at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:291)
at com.voicepro.db.RecordsContentProvider.query(SourceFile:289)
at android.content.ContentProvider$Transport.query(ContentProvider.java:178)
at android.content.ContentResolver.query(ContentResolver.java:311)
at android.support.v4.b.f.loadInBackground(SourceFile:49)
at android.support.v4.b.f.loadInBackground(SourceFile:35)
at android.support.v4.b.a.onLoadInBackground(SourceFile:240)
at android.support.v4.b.b.doInBackground(SourceFile:51)
at android.support.v4.b.b.doInBackground(SourceFile:40)
at android.support.v4.b.q.call(SourceFile:123)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Might be a corrupt or incomplete database. Check on what devices this happens, and possibly try to get a copy of the DB. Not directly related, but try not to obfuscate the support library, some code depend son class/method names.