0
votes

I don't really know why I have this error. The code seems pretty straight forward.

@Entity(indices = {@Index("clientLocalId")})
.
.

private @PrimaryKey String clientLocalId;


public String getClientLocalId() {
    return clientLocalId;
}

public void setClientLocalId(long idInvoice, String receipt) {
    this.clientLocalId = String.valueOf(idInvoice) + " " + receipt;
}

I tried to changed the name in just client, restarted and cleared caches, same error.

error: Cannot find setter for field. private @PrimaryKey String clientLocalId; ^

Any idea is appreciated. Thanks in advance !

2

2 Answers

1
votes

it happened because of the second Parameter receipt of clientLocalId, remove it or add another setter method, i recommend you add receipt to your clientLocalId out of entity class before inserting in Database

0
votes

Room is looking for a setter that just takes a single String value. Your method has two.

Change it to the below and use another method to create your concatenated id.

public void setClientLocalId(String id) {
    this.clientLocalId = id;
}