Cannot complete build because of serializationVersionUID warning

185 views Asked by At

We are currently using greenDAO3 in this project. I believe we were using the greenDAO2 at some point because it seems that we were using the legacy generator class.

So I am attempting to add a new table to the database for a new feature in our application. I am not very familiar with greenDAO, but I figured it would be easier to have it auto-generate the file at build time with Gradle.

Everything works fine, but after adding some stuff to my root.gradle and app.gradle, I get this error.

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).

These are the changes I made.

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
+}
+

When I suppress warnings it proceeds to the next serializable class in the db folder. I really don't want to suppress warnings, because that seems like bad practice in this case.

1

There are 1 answers

5
IQbrod On

Add a serialVersionUID field in your MyClassTest.java
A good pratice might be to set the last modification date

public class MyClassTest {
    private static final long serialVersionUid = 6082019L;
}

More informations available on this post