带有活动android的Android应用程序在启动时关闭

时间:2014-09-13 10:34:48

标签: android activeandroid

我正在使用活动的android orm构建一个应用程序,我在创建所有模型后尝试运行它,当我启动它时应用程序停止。

注意:我没有更新我的模型,这是我第一次在安装活动的android后运行应用程序 并创建我的模型。我也没有创建任何模型实例或者保存了数据库。

logcat的:

09-13 13:26:08.789  27599-27599/com.sqvat.squat W/Xposed﹕ Package name for       /data/app/com.zst.xposed.xuimod-1.apk had to be retrieved via parser
09-13 13:26:08.959  27599-27599/com.sqvat.squat D/dalvikvm﹕ JIT code cache reset in 0 ms (0 bytes 3/0)
09-13 13:26:08.969  27599-27599/com.sqvat.squat D/dalvikvm﹕ GC_FOR_ALLOC freed 341K, 45% free 4755K/8504K, paused 17ms, total 17ms
09-13 13:26:09.160  27599-27599/com.sqvat.squat D/dalvikvm﹕ GC_FOR_ALLOC freed 487K, 45% free 4781K/8676K, paused 17ms, total 18ms
09-13 13:26:09.170  27599-27599/com.sqvat.squat E/SQLiteLog﹕ (1) near "Order": syntax error
09-13 13:26:09.170  27599-27599/com.sqvat.squat D/AndroidRuntime﹕ Shutting down VM
09-13 13:26:09.170  27599-27599/com.sqvat.squat W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415fdba8)
09-13 13:26:09.170  27599-27599/com.sqvat.squat E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.sqvat.squat, PID: 27599
    java.lang.RuntimeException: Unable to create application com.activeandroid.app.Application: android.database.sqlite.SQLiteException: near "Order": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTS CompletedSessions (Id INTEGER PRIMARY KEY AUTOINCREMENT, CompletedWorkout INTEGER REFERENCES CompletedWorkouts(Id) ON DELETE NO ACTION ON UPDATE NO ACTION, Session INTEGER REFERENCES Sessions(Id) ON DELETE NO ACTION ON UPDATE NO ACTION, Order INTEGER);
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4389)
            at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
            at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
            at android.app.ActivityThread.handleBindApplication(Native Method)
            at android.app.ActivityThread.access$1500(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5059)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.database.sqlite.SQLiteException: near "Order": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTS CompletedSessions (Id INTEGER PRIMARY KEY AUTOINCREMENT, CompletedWorkout INTEGER REFERENCES CompletedWorkouts(Id) ON DELETE NO ACTION ON UPDATE NO ACTION, Session INTEGER REFERENCES Sessions(Id) ON DELETE NO ACTION ON UPDATE NO ACTION, Order INTEGER);
            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.SQLiteStatement.<init>(SQLiteStatement.java:31)
            at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1672)
            at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1603)
            at com.activeandroid.DatabaseHelper.createTable(DatabaseHelper.java:138)
            at com.activeandroid.DatabaseHelper.onCreate(DatabaseHelper.java:51)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
            at com.activeandroid.Registry.openDatabase(Registry.java:149)
            at com.activeandroid.Registry.initialize(Registry.java:107)
            at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:8)
            at com.activeandroid.app.Application.onCreate(Application.java:9)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4386)
            at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
            at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
            at android.app.ActivityThread.handleBindApplication(Native Method)
            at android.app.ActivityThread.access$1500(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5059)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
            at dalvik.system.NativeStart.main(Native Method)

我的'CompletedSession'模型:

package com.sqvat.squat.data;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;

@Table(name = "CompletedSessions")
public class CompletedSession extends Model {

    @Column(name = "Session")
    public Session session;

    @Column(name = "CompletedWorkout")
    public CompletedWorkout completedWorkout;

    @Column(name = "Order")
    public int order;

    public CompletedSession() {
        super();
    }
}

'会话'模式:

package com.sqvat.squat.data;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;

@Table(name = "Sessions")
public class Session extends Model {

    @Column(name = "Workout")
    public Workout workout;

    @Column(name = "TargetOrder")
    public int targetOrder;

    @Column(name = "Exercise")
    public Exercise exercise;

    @Column(name = "Rest")
    public int rest;

    public Session() {
        super();
    }
}

和'CompletedWorkout'模型:

package com.sqvat.squat.data;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Select;

import java.util.List;

@Table(name = "CompletedWorkouts")
public class CompletedWorkout extends Model {

    @Column(name = "Workout")
    public Workout workout;

    @Column(name = "Date")
    public String date;

    public CompletedWorkout(){
        super();
    }

    public static List<CompletedWorkout> getAll() {
        return new Select()
                .from(CompletedWorkout.class)
                .execute();
    }

}

1 个答案:

答案 0 :(得分:1)

我发现了问题:SET和ORDER是保留字......