SugarORM错误或缺少数据库 [英] SugarORM error or missing database
问题描述
我试图获得一个与SugarORM一起使用的Android项目.但是,我遇到以下错误:
I have tried to get an Android Project working with SugarORM. However, I am running into the following error:
由以下原因引起:android.database.sqlite.SQLiteException:无此类表:DOCUMENT(代码1):,而在编译时:INSERT或REPLACE INTO DOCUMENT(ID,CREATED)值(?,?) ################################################ ############### 错误代码:1(SQLITE_ERROR) 引起原因:SQL(query)错误或数据库丢失. (没有这样的表:DOCUMENT(代码1):,而在编译时:插入或替换为DOCUMENT(ID,CREATED)值(?,?) ################################################ ###############
Caused by: android.database.sqlite.SQLiteException: no such table: DOCUMENT (code 1): , while compiling: INSERT OR REPLACE INTO DOCUMENT(ID,CREATED) VALUES (?,?) ################################################################# Error Code : 1 (SQLITE_ERROR) Caused By : SQL(query) error or missing database. (no such table: DOCUMENT (code 1): , while compiling: INSERT OR REPLACE INTO DOCUMENT(ID,CREATED) VALUES (?,?)) #################################################################
在我的AndroidManifest中,我在应用程序中定义了android:name="com.orm.SugarApp"
-标记并包含
In my AndroidManifest I have defined the android:name="com.orm.SugarApp"
in my application - Tag and included
<meta-data android:name="DATABASE" android:value="idea.db" />
<meta-data android:name="VERSION" android:value="1" />
也用作子标签.我已删除
also as child tags. I have removed
<meta-data android:name="QUERY_LOG" android:value="true" />
<meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.example" />
来自示例,因为它们没有任何改变(,其他人成功删除了它们).我尝试先查询数据库(使用findById)以强制创建表",如这篇文章.此外,我尝试做类似的事情
from the example as they don't change anything (and others had success in removing them). I have tried to Query the db first (with findById) to "force table creation" as explained in this post. Furthermore, I have tried doing something like
SugarDb sugarDb = new SugarDb(getApplicationContext()); new
File(sugarDb.getDB().getPath())
如此处所述.出色地.此外,我已经禁用了InstantRun功能,如一些帖子和此处所述(糖ORM否这样的表异常).
as described here.But this runs in an error as well. Furthermore I have disabled the InstantRun-Feature as described in a few posts and here (Sugar ORM No such table exception).
有人能为我指出正确的方向,如何摆脱错误或缺少数据库"错误吗?
Can anybody point me the right direction how to get rid of the "error or missing database"-error?
推荐答案
如果您使用ProGuard,则必须编辑 proguard-rules.pro
If you use ProGuard you must edit proguard-rules.pro
将此行添加到结尾. 模型文件夹中的我的SugarRecords"(模型).
Add this line to end. My SugarRecords ( models ) in models folder.
-keep class com.username.appname.models.** { *; }
并在Android Studio中禁用即时运行功能. 我为SugarORM安装编写了一个教程这里
And disable Instant Run function in Android Studio. I wrote a tutorial for SugarORM installation here
这篇关于SugarORM错误或缺少数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!