我们目前在这个项目中使用greenDAO3。我相信我们在某种程度上使用了greenDAO2,因为我们似乎使用了遗留的生成器类。
因此,我尝试为应用程序中的新功能添加一个新表到数据库中。我不太熟悉greenDAO,但我觉得让它在构建时使用Gradle自动生成文件会更容易。
一切正常,但是在我的root.gradle和app.gradle中添加了一些东西后,我得到了这个错误。
ERROR: Found 1 problem(s) parsing "/Users/Dustin/Projects/project/app/src/main/java/com/package1/package2/db/MyClassTest.java". First problem:
Pb(96) The serializable class MyClassTest does not declare a static final serialVersionUID field of type long (536871008 at line 18).这些是我所做的更改。
diff --git a/app/build.gradle b/app/build.gradle
index 40b3b80d..60f2a688 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,4 +1,7 @@
apply plugin: 'com.android.application'
+apply plugin: 'com.google.gms.google-services'
+apply plugin: 'org.greenrobot.greendao'
+apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
@@ -234,4 +237,7 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
-apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
+greendao {
+ schemaVersion 24
+}
+当我禁止显示警告时,它会转到db文件夹中的下一个可序列化的类。我真的不想抑制警告,因为在这种情况下,这似乎是一种糟糕的做法。
发布于 2019-08-06 22:49:04
在MyClassTest.java中添加serialVersionUID字段
一个不错的做法可能是设置上次修改日期
public class MyClassTest {
private static final long serialVersionUid = 6082019L;
}此post上提供了更多信息
https://stackoverflow.com/questions/57378593
复制相似问题