SugarORM error or missing database - android

I have tried to get an Android Project working with SugarORM. However, I am running into the following error:
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 (?,?))
#################################################################
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" />
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())
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?

Are you sure <meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="com.example" /> doesn't change anything? Your link supporting that doesn't seem to go to the correct place. Regardless, follow the examples until the issue is fixed, then worry about what can be trimmed away!
You shouldn't need to be looking at the database file, not really sure why that's included.
Does your Document class extends SugarRecord? Without that, the table won't be created.
In general I think you should try running through the "Getting Started" again from scratch, without making any modifications to the code on the way.

i had the same problem and in my case, it turned out that sugar orm version 1.4 had issues. Just update your gradle dependency to compile 'com.github.satyan:sugar:1.5' This solved my problem

If you use ProGuard you must edit proguard-rules.pro
Add this line to end.
My SugarRecords ( models ) in models folder.
-keep class com.username.appname.models.** { *; }
And disable Instant Run function in Android Studio.
I wrote a tutorial for SugarORM installation here

Related

AndroidManifest.xml merger failing, cached intermediate file Visual Studio Xamarin Forms Android

Strange problem with Manifest Merger, Visual Studio Mac, Xamarin Forms (5.0.0.2125), Android project, SDK 29 to 30. Problem initiated from an extra ">" in the Properties/AndroidManifest.xml file. That generated the error below, indicating the xml structure wasn't closed; line 35, column 11 being was the last line and character of the Properties/AndroidManifest.xml.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error AMM0000: Error: org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 11; XML document structures must start and end within the same entity. (AMM0000)
So, I edited out the extra character, and the obj/debug/AndroidManifest.xml is created and looks right, however, the build error remains the same!
Subsequent complete rewrites and edits of the Properties/AndroidManifest.xml file have only 2 outcomes
Entering an erroneous xml format will generate the appropriate errors describing the error.
Entering a correct xml format, with any combination of entries, lines and characters will generate a correct obj/debug/AndroidManifest.xml file with the the correct Properties/AndroidManifest.xml content. However, the original build errors stay, with the " line 35, column 11 being was the last line and character of the Properties/AndroidManifest.xml." error.
So, something cached, somewhere, but no clue where. Started during an aborted simulator build and has been here ever since.
Have tried quite few things including:
cleaning, rebuilding and many combinations
remove obj and bin
removing/adding declarations in the AndroidManifest.xml
using different AndroidManifest.xml files
deleting AndroidManifest.xml and running
restoring from cloud a different version of solutions
commenting out Activity declaration on MainActivity
reinstall of VS for Mac
I think it is similar to this bug
Xamarin android Manifest being replaced on build. only solution seems to be to repair visual studio
Has anyone seen this type of bug before?
Help much appreciated as have run out of ideas here.
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="17" android:versionName="1.17" package="com.mycompany.myapp">
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="30" />
<application android:label="myapp" android:icon="#mipmap/ic_launcher" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Solved here, github.com/xamarin/xamarin-android/issues/6385. Was a problem in a Nuget Firebase library AndroidManifest.xml file. Unfortunately the error reporting in VS Mac Manifest merging doesn't report which of the 140+ AndroidManifest.xml files has the problem. However, with a bit of sleuthing, there is a way to eventually work it out.

Lint check "RemoveWorkManagerInitializer" fails, how to fix that?

My App class implements Configuration.Provider.getWorkManagerConfiguration, and regarding this article: https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration#on-demand
I switched default initializer with this string in my AndroidManifest.xml:
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
tools:node="remove" />
The code works as I need - no default initializer calls, but the only Configuration.Provider.getWorkManagerConfiguration.
If I run lint check I still see the error: Remove androidx.work.impl.WorkManagerInitializer when using on-deman initialization.
Android studio 4.1 beta 5
Gradle plugin: 4.1.0-beta05
Work manager: 2.3.4
Any thoughts on how to deal with it?

Get Error In New App Version: No Such Table

I read a lot of related posts, but I didn't get the solution.
I use the ActiveAndroid library for the database and released my program, but I having trouble in updating the new version.
In the new version of the application, a table is added to the database. Therefore, the database must be updated.
(I made the changes and increased the database version ).
manifest file:
<meta-data
android:name="AA_DB_NAME"
android:value="KashanTakhfifi" />
<meta-data
android:name="AA_DB_VERSION"
android:value="2" />
<meta-data
android:name="AA_MODELS"
android:value="DBTableModel.TableNotificationModel, DBTableModel.TableGuideModel" />
But when the new app is install or update,The program will be crash.
because happen error: no such table(which means the database is not updated).
I read in the other posts : the app should be removed and reinstalled.
But I've released the app and this problem is not logical for users.
If I want to delete this library, I will have to make a lot of changes to my code...
What is the solution for me.

How to resolve errors produced by deleting google_maps_api.xml?

I am using this library for displaying directions: https://github.com/akexorcist/Android-GoogleDirectionLibrary/blob/master/app/src/main/java/com/akexorcist/googledirection/sample/SimpleDirectionActivity.java. Previously I created a google maps activity, and the google_maps_api.xml was generated. I deleted this file because I don't believe I need it anymore, but now I get an error in my manifest file saying
"No resources found that match the given name(at 'value' with value '#string/google_maps_key') Can I simply delete the meta data tage seen below or is there a better option to clean things up?
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />

Failed to find provider info for ContentProvider

I have seen a few similar posts to this, but i already have had the ContentProvider registered in my AndroidManifest.
I have a ContentProvider called MyContentProvider.
And MyContentProvider is located in a library project called MyProject. With package location personal.mobile.abc.angry.tiger.MyContentProvider.
My AndroidManifest for this project looks like this (left out info that is not related):
<application
android:label=...
android:icon=...
android:theme=...>
<provider
android:name="personal.mobile.abc.angry.tiger.MyContentProvider"
android:authorities="personal.mobile.abc.angry.tiger">
</provider>
</application>
Lint keeps saying this:
The <provider> personal.mobile.abc.angry.tiger.MyContentProvider is not registered in the manifest.
And Logcat says this when attempting to run the application that includes the library that contains the ContentProvider:
Failed to find provider info for personal.mobile.abc.angry.tiger
What am i doing wrong? What is the issue?
If you need any further information, please let me know.
Thanks!
Your <provider> element needs to be in the application, as it is the one with the ContentProvider. The fact that the Java class implementing that ContentProvider happens to be in an Android library project does not change the fact that the hosting app is the one responsible for that provider.
Eventually -- perhaps as soon as ADT 21 -- your <provider> element in the library project can be automatically added to your application project. Right now, AFAIK, that process is manual.

Categories

Resources