无法在Android AVD上运行我的项目

时间:2013-01-09 04:30:23

标签: java android eclipse

我尝试在android上测试数据库。我想在sumsung GALAXY TAB中运行我的项目。所以,我设置AVD是Galaxy Nexus,RAM = 512,VM Heap = 64,SD卡= 1024 MiB。我创建的android项目名称是SQLiteDatabase。当我在AVD上运行SQLiteDatabase时,它显示此错误。  

不幸的是,SQLite数据库已停止。

我不知道为什么我无法运行SQLiteDatabase项目这是来自logcat的错误。

01-09 04:17:27.347: I/Process(6519): Sending signal. PID: 6519 SIG:9
     01-09 04:17:33.517: W/Trace(6848): Unexpected value from nativeGetEnabledTags: 0
     01-09 04:17:33.517: W/Trace(6848): Unexpected value from nativeGetEnabledTags: 0
     01-09 04:17:33.562: W/Trace(6848): Unexpected value from nativeGetEnabledTags: 0
     01-09 04:17:33.562: W/Trace(6848): Unexpected value from nativeGetEnabledTags: 0
     01-09 04:17:34.917: D/dalvikvm(6848): GC_CONCURRENT freed 75K, 7% free 2744K/2948K, paused 12ms+6ms, total 122ms
     01-09 04:17:34.917: D/dalvikvm(6848): WAIT_FOR_CONCURRENT_GC blocked 71ms
     01-09 04:17:34.937: I/dalvikvm-heap(6848): Grow heap (frag case) to 3.868MB for 1127536-byte allocation
     01-09 04:17:35.027: D/dalvikvm(6848): GC_FOR_ALLOC freed 2K, 6% free 3843K/4052K, paused 84ms, total 85ms
     01-09 04:17:35.227: D/dalvikvm(6848): GC_CONCURRENT freed <1K, 6% free 3847K/4052K, paused 10ms+4ms, total 199ms
     01-09 04:17:35.347: E/SQLiteLog(6848): (1) near "tabletool": syntax error
     01-09 04:17:35.359: D/AndroidRuntime(6848): Shutting down VM
     01-09 04:17:35.359: W/dalvikvm(6848): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
     01-09 04:17:35.417: E/AndroidRuntime(6848): FATAL EXCEPTION: main
     01-09 04:17:35.417: E/AndroidRuntime(6848): java.lang.RuntimeException: Unable to start activity
 ComponentInfo{com.example.sqlitedatabase/com.example.sqlitedatabase.MainActivity}:
 android.database.sqlite.SQLiteException: near "tabletool": syntax
 error (code 1): , while compiling: create tabletool(idinteger primary
 key autoincrement ,nametext ,amountnumericunitunit
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.os.Handler.dispatchMessage(Handler.java:99)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.os.Looper.loop(Looper.java:137)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.ActivityThread.main(ActivityThread.java:5039)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at java.lang.reflect.Method.invokeNative(Native Method)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at java.lang.reflect.Method.invoke(Method.java:511)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at dalvik.system.NativeStart.main(Native Method)
     01-09 04:17:35.417: E/AndroidRuntime(6848): Caused by: android.database.sqlite.SQLiteException: near "tabletool": syntax
 error (code 1): , while compiling: create tabletool(idinteger primary
 key autoincrement ,nametext ,amountnumericunitunit
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native
 Method)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1663)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at com.example.sqlitedatabase.SimpleSQLiteHelper.onCreate(SimpleSQLiteHelper.java:43)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at com.example.sqlitedatabase.ToolDataSource.open(ToolDataSource.java:28)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at com.example.sqlitedatabase.MainActivity.onCreate(MainActivity.java:36)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.Activity.performCreate(Activity.java:5104)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
     01-09 04:17:35.417: E/AndroidRuntime(6848):     ... 11 more

2 个答案:

答案 0 :(得分:2)

ComponentInfo{com.example.sqlitedatabase/com.example.sqlitedatabase.MainActivity}: android.database.sqlite.SQLiteException: near "tabletool": syntax error (code 1): , while compiling: create tabletool(idinteger primary key autoincrement ,nametext ,amountnumericunitunit 01-09 04:17:35.417: E/AndroidRuntime(6848): at 

没有相关的代码可用,但基于上面的异常堆栈,您似乎在create table“tabletool”中有一些语法错误

确保create table语法有效(空格,冒号等,如果需要)。

答案 1 :(得分:1)

嘿,在日志中我发现你的表查询错误。

像这样更改此查询

create tabletool(id integer primary key autoincrement ,name text

我只能在日志中看到两个忘记维护空间的参数。在参数和数据类型之间放置空格并尝试它。它适合你。

检查您的查询,将其写为idintegernametext,该id integername text