You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
whenever I add a @PrimaryKey(autoincrement = true) to a model I got the following exception
java.lang.RuntimeException: Unable to create application com.zlagup.app.ZlagUpApplication: android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1): , while compiling: CREATE TABLE IF NOT EXISTS set_stats(id INTEGER(0) PRIMARY KEY AUTOINCREMENT, completed INTEGER(0), set_id INTEGER, stats_id INTEGER, FOREIGN KEY(set_id) REFERENCES set (id) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(stats_id) REFERENCES stats (id) ON UPDATE CASCADE ON DELETE CASCADE );
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Tried to change the datatype of the field from long to int but without success (Cleaning and reinstalling app didn't solved the problem). Did you experience such a problem in the past. I looked through the old issues but couldn't find something similar.
Update: Tried to investigate a bit on this issue and saw that removing the column length "(0)" after the data type within the create statement seems to solve the problem. Found this in the official SQLite docs:
"Note that numeric arguments in parentheses that following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values."
The text was updated successfully, but these errors were encountered:
Hi,
(using version 2.1.0)
whenever I add a @PrimaryKey(autoincrement = true) to a model I got the following exception
java.lang.RuntimeException: Unable to create application com.zlagup.app.ZlagUpApplication: android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1): , while compiling: CREATE TABLE IF NOT EXISTS
set_stats
(id
INTEGER(0) PRIMARY KEY AUTOINCREMENT,completed
INTEGER(0),set_id
INTEGER,stats_id
INTEGER, FOREIGN KEY(set_id
) REFERENCESset
(id
) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(stats_id
) REFERENCESstats
(id
) ON UPDATE CASCADE ON DELETE CASCADE );at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4521)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Tried to change the datatype of the field from long to int but without success (Cleaning and reinstalling app didn't solved the problem). Did you experience such a problem in the past. I looked through the old issues but couldn't find something similar.
Update: Tried to investigate a bit on this issue and saw that removing the column length "(0)" after the data type within the create statement seems to solve the problem. Found this in the official SQLite docs:
"Note that numeric arguments in parentheses that following the type name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not impose any length restrictions (other than the large global SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric values."
The text was updated successfully, but these errors were encountered: