I'm using greenDAO for a long time in my app without any problem!
But after migrating my project to using androidX , I received an Exception (org.greenrobot.greendao.DaoException) like below.
Non-fatal Exception: org.greenrobot.greendao.DaoException: app.myapp.models.database.LocationDao#9eff3d3 (LOCATION) does not have a single-column primary key
at org.greenrobot.greendao.AbstractDao.assertSinglePk(AbstractDao.java:917)
at org.greenrobot.greendao.AbstractDao.load(AbstractDao.java:135)
at app.myapp.views.activities.LocationDetailActivity.putLocationDetails(LocationDetailActivity.java:707)
at app.myapp.views.activities.-$$Lambda$ZJfQ3ya-jyJgM_oHuJ1u29_DoCw.run(-.java)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
I searched a lot in google for solving this problem but I didn't find an answer helping me.
And this is my model class codes:
public class Location {
#Id (autoincrement = true)
#SerializedName("LocationID")
private long locationID;
#SerializedName("LocationCategoryID")
private long locationCategoryID;
#SerializedName("LocationTitleFA")
private String locationTitleFA;
#SerializedName("LocationTitleEN")
private String locationTitleEN;
#SerializedName("PictureAddress")
private String pictureAddress;
#Generated(hash = 591434765)
public Location(long locationID, long locationCategoryID,
String locationTitleFA, String locationTitleEN, String pictureAddress) {
this.locationID = locationID;
this.locationCategoryID = locationCategoryID;
this.locationTitleFA = locationTitleFA;
this.locationTitleEN = locationTitleEN;
this.pictureAddress = pictureAddress;
}
#Generated(hash = 375979639)
public Location() {
}}
and setter and getters...
Could anyone help me?!
Related to Mr. Markus Junginger's comment, I fixed issue:
"Release mode" is probably a good lead. Please check the following links: github.com/greenrobot/greenDAO#r8-proguard, developer.android.com/jetpack/androidx/migrate, github.com/objectbox/objectbox-java/issues/….
I updated my greendao Proguard codes and fixed problem.
A line of codes was:
-dontwarn org.greenrobot.greendao.database.
Changed to:
-dontwarn net.sqlcipher.database.**
Related
I have hit a small issue and hoping someone might be able to assist. I am using a panel - On the page load, it should list all the products as no category has been selected as per stored procedure (this works perfectly).
When a user clicks on a specific category, it should only show the products that have the specific CategoryID. When I run the code in SQL, it works a dream for this part too, so assume the stored procedure is ok.
At
CategoryID = CategoryID
in GetProducts, I get
Warning: Assignment made to same variable; did you mean to assign something else?
However I am following a tutorial video and this works fine. Is there another silly error that is preventing it from working?
I think I have included all the required code - sorry if its a bit overkill!!
Thanks as ever in advance - Jack
Code behind pnlCategories:
private void GetProducts(int CategoryID)
{
ShoppingCart k = new ShoppingCart();
{
CategoryID = CategoryID;
};
Error identified - additional ";" added at following line:
ShoppingCart k = new ShoppingCart();
Code now reads
ShoppingCart k = new ShoppingCart()
{
CategoryID = CategoryID
};
and functions as expected!
that looks like a c# error and not a SQL Server error.
The problem is here in your GetProducts method. CategoryID = CategoryID;
C# is case sensitive. If you check your tutorial carefully, one of these will probably be lower case. Make sure you type that carefully.
try code change below and see where the compiler complains.
CategoryID = categoryID;
private void GetProducts(int CategoryID)
{
ShoppingCart k = new ShoppingCart();
{
CategoryID = CategoryID;
};
dlProducts.DataSource = null;
dlProducts.DataSource = k.GetProdcuts();
dlProducts.DataBind();
}
I'm using Retrofit and I want to make a request with tge delete method. I want to use a specific body, but the delete method doesn't support that. I created my custom class for delete method like this:
#Target(METHOD)
#Retention(RUNTIME)
#RestMethod( hasBody = true,value = "DELETE")
public #interface CustomDelete {
String value();
}
But when I use it I have this error:
10-31 16:24:09.459: I/System.out(21090): retrofit.RetrofitError: DELETE does not support writing
Try this (with Retrofit 2.0):
#FormUrlEncoded
#HTTP(method = "DELETE", path = "/api/resource/etc", hasBody = true)
Call<ApiResponse> deleteSomething(#Field("id") int id);
#HTTP(method = "DELETE",path="/api/v1/media/{username}/{accesstoken}", hasBody = true)
Call<MyResponse> deleteArchiveMedia(#Path("username") String username, #Path("accesstoken") String token ,
#Body DeleteMedia deleteMedia);
I am having a issue with the DELETE as well but a more basic one and found this discussion. It seems to me that it might answer your question.
https://github.com/square/retrofit/issues/426
My issue is, that whenever I define my interface it gives me a syntax error on METHOD and RUNTIME.
Do I need to include something somewhere to be able to use it?
I accidentally removed the references from one of my projects and then carefully put them back in. However now I am throwing errors in code the was functioning perfectly so I think I must still be missing a reference unless something else was broken in the process. Here is the current error:
The variable 'button1' is either undeclared or was never assigned.
But here is the code in Form1.Designer.cs:
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
...
//
// button1
//
this.button1.Location = new System.Drawing.Point(235, 382);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(125, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Generate Report";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
...
this.Controls.Add(this.button1);
...
private System.Windows.Forms.Button button1;
The last seven lines are all throwing this error. Any advice is appreciated.
Regards.
EDIT: Here is code relevant to the comments:
public partial class Severity3RetailNetworkTrackingLog : Form
{
public Severity3RetailNetworkTrackingLog()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
Where Form1 has been changed to Severity3RetailNetworkTrackingLog.
I suspect you are missing the member variable definition
class Form1 {
/* lots of windows form designer code */
/* some other member variables */
System.Windows.Forms.Button button1;
}
Within your class definition.
Turns out that VS Express 2010 was just misbehaving. I commented out all of the offending code and still got the same errors with the same line numbers. So I closed and opened VS and everything is back to normal.
For those familiar with automated testing tools, you know that they all have some kind of "object repository" that stores a mapping of UI elements with identifiers. I have found this to be indispensible and I want to duplicate this for webdriver. Has anyone done this ? Any tips ? Google not helping on this one. C# examples if you can, thanks
I use Webinator (which wraps around WebDriver) but the idea is the same - I usually do a static "Map" class like so:
public static class CollectionMap
{
public static Locator
LocatorTitle = new Locator(FindBy.Id, "Title"),
LocatorDescription = new Locator(FindBy.Id, "Description"),
LocatorSave = new Locator(FindBy.Id, "submit"),
LocatorDelete = new Locator(FindBy.XPath, "//*[contains(#class,'deleteBox')]/a"),
LocatorDeleteConfirm = new Locator(FindBy.Id, "delete-collection-dialogConfirmationLink"),
LocatorCancel = new Locator(FindBy.Id, "cancel");
}
Used like this:
web.Click(CollectionMap.LocatorSave, WaitUntil.AjaxOrPostCompleted());
I am creating multiple classes containing mappings to locators. Each class corresponds to a logical grouping of screen elements.
public class TopLevel
{
public const string username = "ctl00_ctl00_Main_Main_txtUsername";
}
I want strore a xml file in registry and after restore it.Do it possible?
i try create with this code But it Not Responding?!what is problem?
enter code here
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
MemoryStream stream = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
List<int> f = new List<int>();
f.Add(4);
formatter.Serialize(stream, f);
byte[] binary = stream.ToArray();
string yu = Encoding.UTF8.GetString(binary);
RegistryKey key = Registry.Users;
RegistryKey key2 = key.OpenSubKey(".DEFAULT", true);
key2.SetValue("my4",yu,RegistryValueKind.String ); // "why writed empty string in registry
}
}
A few remarks on this:
1: The registry isn't the right place to save a whole XML file. More normal might be to save the xml to the filesystem and possibly save its location in the registry.
2: Registry.Users refers to a location in the registry where you wouldn't normally save data. Either it should be in HKey_Current_User (Registry.CurrentUser) or HKey_Local_Machine (Registry.LocalMachine) depending on whether the data is specific to all users on the PC or just the current user.
3: I'm extremely confused about what the coding in the first two questions is trying to achieve. Its a long way around to make a string, the contents may not be compatible with the registry and I can see anything related to XML.
I would make a strong warning that updating the registry without knowing exactly what you're doing is very dangerous. It could easily lead to odd errors or even a non-booting PC. Only proceed with trying registry updates once you fully understand how it works. I would start with an article like this one and read on from there.