0

I am an android developer, I used Firebase database for my app. I run the app with app_debug.apk it works fine, but app_release.apk doesn't, it can't load Firebase database. I checked the log file and I got this:

    No setter/field for xxx found on class
    [ex: xxx is a field in Post model]

I checked this post before: No setter/field for xxx found on class link and release apk doesn't load data link ,but they don't help me. This is my model class:

abstract public class BaseModel {
public String userPhotoUrl= "";
public String contentPhotoUrl = "";
public BaseModel(){}

public BaseModel(String userPhotoUrl, String contentPhotoUrl) {
    this.userPhotoUrl = userPhotoUrl;
    this.contentPhotoUrl = contentPhotoUrl;
}

public String getUserPhotoUrl() {
    return userPhotoUrl;
}

public void setUserPhotoUrl(String userPhotoUrl) {
    this.userPhotoUrl = userPhotoUrl;
}

public String getContentPhotoUrl() {
    return contentPhotoUrl;
}

public void setContentPhotoUrl(String contentPhotoUrl) {
    this.contentPhotoUrl = contentPhotoUrl;
}

}

and

public class Post extends BaseModel{
protected String id ="";
protected String userId ="";
protected String userName = "";
protected String content = "";
protected int likeCount = 0;
protected int commentCount = 0;
protected long dataInverse = 0L; /*Use to sort data base publish experience*/
protected long sharedDate = 0L; /*TimeStamp in minisecond - The date expert shared.*/
protected String sharedSourceFrom = ""; /*From facebook or app*/
protected String facebookPostUrl = "";
public Post(){}

public Post(String id, String userId, String userName, String userPhotoUrl, String content, String contentPhotoUrl, int likeCount, int commentCount, long sharedDate, String sharedSourceFrom) {
    super(userPhotoUrl, contentPhotoUrl);
    this.id = id;
    this.userId = userId;
    this.userName = userName;
    this.userPhotoUrl = userPhotoUrl;
    this.content = content;
    this.contentPhotoUrl = contentPhotoUrl;
    this.likeCount = likeCount;
    this.commentCount = commentCount;
    this.dataInverse = 0 - sharedDate;
    this.sharedDate = sharedDate;
    this.sharedSourceFrom = sharedSourceFrom;
    this.facebookPostUrl = "";
}
public String getUserPhotoUrl() {
    return userPhotoUrl;
}

public void setUserPhotoUrl(String userPhotoUrl) {
    this.userPhotoUrl = userPhotoUrl;
}

public String getContentPhotoUrl() {
    return contentPhotoUrl;
}

public void setContentPhotoUrl(String contentPhotoUrl) {
    this.contentPhotoUrl = contentPhotoUrl;
}
public String getId() {
    return id;
}

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

public String getUserId() {
    return userId;
}

public void setUserId(String userId) {
    this.userId = userId;
}

public String getUserName() {
    return userName;
}

public void setUserName(String userName) {
    this.userName = userName;
}

public String getContent() {
    return content;
}

public void setContent(String content) {
    this.content = content;
}

public int getLikeCount() {
    return likeCount;
}

public void setLikeCount(int likeCount) {
    this.likeCount = likeCount;
}

public int getCommentCount() {
    return commentCount;
}

public void setCommentCount(int commentCount) {
    this.commentCount = commentCount;
}

public long getDataInverse() {
    return dataInverse;
}

public void setDataInverse(long dataInverse) {
    this.dataInverse = dataInverse;
}

public long getSharedDate() {
    return sharedDate;
}

public void setSharedDate(long sharedDate) {
    this.sharedDate = sharedDate;
}

public String getSharedSourceFrom() {
    return sharedSourceFrom;
}

public void setSharedSourceFrom(String sharedSourceFrom) {
    this.sharedSourceFrom = sharedSourceFrom;
}

public String getFacebookPostUrl() {
    return facebookPostUrl;
}

public void setFacebookPostUrl(String facebookPostUrl) {
    this.facebookPostUrl = facebookPostUrl;
}

}

This is a datasnapshoot in Firebase databaseenter image description here

Do you have any suggestion to resolve this problem ?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Zappy.Mans
  • 551
  • 1
  • 7
  • 19
  • Put a `@Keep` annotation on your `Post` class (and possibly also on your `BaseModel`). Also see my answer from yesterday here: https://stackoverflow.com/questions/45010923/firebase-writes-different-files-if-app-is-debug-or-release-version/45014035#45014035 – Frank van Puffelen Jul 12 '17 at 04:03
  • Do you mean: before class name like this: "@Keep abstract public class BaseModel {" right ? – Zappy.Mans Jul 12 '17 at 04:06
  • It works. Thanks, Frank. – Zappy.Mans Jul 12 '17 at 04:13

0 Answers0