Firestore:在 class 上找不到要序列化的属性
Firestore : No properties to serialize found on class
注:
请不要将此问题标记为重复,因为我已经看过类似的问题及其答案。
错误:
java.lang.RuntimeException: No properties to serialize found on class com.appz.abhi.shudhbatter.b.c
at com.google.firebase.firestore.g.l$a.(Unknown Source)
at com.google.firebase.firestore.g.l.a(Unknown Source)
at com.google.firebase.firestore.g.l.b(Unknown Source)
at com.google.firebase.firestore.g.l.b(Unknown Source)
at com.google.firebase.firestore.g.l.a(Unknown Source)
at com.google.firebase.firestore.ah.b(Unknown Source)
at com.google.firebase.firestore.b.a(Unknown Source)
at com.appz.abhi.shudhbatter.view.onboarding.a.a.a.a(Unknown Source)
at com.appz.abhi.shudhbatter.view.onboarding.a.a.a.lambdab6vrtW7GJri_HgEDiOk1aRbrY(Unknown
Source)
at com.appz.abhi.shudhbatter.view.onboarding.a.a.-$$Lambda$ab6vrtW7GJri_HgEDiOk1aRbrY.onClick(lambda)
at android.view.View.performClick(View.java:5647)
at android.view.View$PerformClick.run(View.java:22465)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6238)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
类似问题:
- No properties to serialize found on class com.contentful.vault.Asset
proguard-rules.pro:
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
# Add this global rule
-keepattributes Signature
-keep class android.support.v7.widget.RecyclerView { *; }
# Keep custom model classes
-keepclassmembers class com.mypackage.model.** { *; }
-keep class com.mypackage.model.** { *; }
-keep class com.mypackage.util.** { *; }
使用映射文件,我发现错误是由以下模型引起的class:
User.java:
package com.mypackage.model;
import java.io.Serializable;
public class User implements Serializable {
// Data
private Long phone;
private String uid, name, mail, apartmentName, doorNo;
private UserType userType;
public User() {
userType = UserType.USER;
}
public Long getPhone() {
return phone;
}
public void setPhone(Long phone) {
this.phone = phone;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getApartmentName() {
return apartmentName;
}
public void setApartmentName(String apartmentName) {
this.apartmentName = apartmentName;
}
public String getDoorNo() {
return doorNo;
}
public void setDoorNo(String doorNo) {
this.doorNo = doorNo;
}
public UserType getUserType() {
return userType;
}
public void setUserType(UserType userType) {
this.userType = userType;
}
}
UserType.java:
package com.mypackage.model;
public enum UserType {
USER, ADMIN, DELIVERY
}
以上错误在执行以下操作后得到解决:
- 清理并重建项目。
- 正在删除所有混淆规则。
- 在每个模型 class 开头添加
@Keep
。
注:
请不要将此问题标记为重复,因为我已经看过类似的问题及其答案。
错误:
java.lang.RuntimeException: No properties to serialize found on class com.appz.abhi.shudhbatter.b.c
at com.google.firebase.firestore.g.l$a.(Unknown Source)
at com.google.firebase.firestore.g.l.a(Unknown Source)
at com.google.firebase.firestore.g.l.b(Unknown Source)
at com.google.firebase.firestore.g.l.b(Unknown Source)
at com.google.firebase.firestore.g.l.a(Unknown Source)
at com.google.firebase.firestore.ah.b(Unknown Source)
at com.google.firebase.firestore.b.a(Unknown Source)
at com.appz.abhi.shudhbatter.view.onboarding.a.a.a.a(Unknown Source)
at com.appz.abhi.shudhbatter.view.onboarding.a.a.a.lambdab6vrtW7GJri_HgEDiOk1aRbrY(Unknown Source)
at com.appz.abhi.shudhbatter.view.onboarding.a.a.-$$Lambda$ab6vrtW7GJri_HgEDiOk1aRbrY.onClick(lambda)
at android.view.View.performClick(View.java:5647)
at android.view.View$PerformClick.run(View.java:22465)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6238)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
类似问题:
- No properties to serialize found on class com.contentful.vault.Asset
proguard-rules.pro:
-assumenosideeffects class android.util.Log {
public static *** d(...);
}
# Add this global rule
-keepattributes Signature
-keep class android.support.v7.widget.RecyclerView { *; }
# Keep custom model classes
-keepclassmembers class com.mypackage.model.** { *; }
-keep class com.mypackage.model.** { *; }
-keep class com.mypackage.util.** { *; }
使用映射文件,我发现错误是由以下模型引起的class:
User.java:
package com.mypackage.model;
import java.io.Serializable;
public class User implements Serializable {
// Data
private Long phone;
private String uid, name, mail, apartmentName, doorNo;
private UserType userType;
public User() {
userType = UserType.USER;
}
public Long getPhone() {
return phone;
}
public void setPhone(Long phone) {
this.phone = phone;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail;
}
public String getApartmentName() {
return apartmentName;
}
public void setApartmentName(String apartmentName) {
this.apartmentName = apartmentName;
}
public String getDoorNo() {
return doorNo;
}
public void setDoorNo(String doorNo) {
this.doorNo = doorNo;
}
public UserType getUserType() {
return userType;
}
public void setUserType(UserType userType) {
this.userType = userType;
}
}
UserType.java:
package com.mypackage.model;
public enum UserType {
USER, ADMIN, DELIVERY
}
以上错误在执行以下操作后得到解决:
- 清理并重建项目。
- 正在删除所有混淆规则。
- 在每个模型 class 开头添加
@Keep
。