Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@79d6c4df

I keep getting this error. I am working on a project and in the middle of development, I decided to migrate to Android X.

I get the error below:

Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@79d6c4df

There is the same error in a entity file and 4 of the same error in the respective DAO as well.

Here is the code of DAO:

@Dao
public interface FlockDao{
    @Query("SELECT * FROM flock_table")
    LiveData<List<Flock>> getAllFlocks();

    @Query("SELECT * FROM flock_table WHERE fid IN (:flockIds) LIMIT 1")
    Flock loadFlockById(int[] flockIds);

    @Insert
    void insert(Flock flock);

    @Update
    void update(Flock flock);

    @Delete
    void delete(Flock flock);
}

And my entity is:

@Entity
public class Flock{

    @PrimaryKey(autoGenerate = true)
    private int fid;

    @ColumnInfo(name = "user_id")
    private int uid;

    @ColumnInfo(name = "name")
    private String name;

    @ColumnInfo(name = "capacity")
    private int capacity;

    @ColumnInfo(name = "type")
    private String type;

    @ColumnInfo(name = "arrived")
    private Date arrived;

    .....rest of the code is omitted, there are constructor, setters and getters
}
like image 514
dawn Avatar asked Mar 17 '19 11:03

dawn


4 Answers

I updated my Room depency to 2.1.0-alpha05 and got the same problem. Returning to 2.1.0-alpha04 solved mine.

implementation 'androidx.room:room-runtime:2.1.0-alpha04'
annotationProcessor 'androidx.room:room-compiler:2.1.0-alpha04'

UPDATE If you really want to use Room version 2.1.0-alpha05, add the following depency to your project repository:

maven { url 'https://kotlin.bintray.com/kotlinx/' }

Reference: AndroidX Room Release Notes

UPDATE I tried 2.1.0-alpha06.

implementation 'androidx.room:room-runtime:2.1.0-alpha06'
annotationProcessor 'androidx.room:room-compiler:2.1.0-alpha06'

Then I add the depency to my project repository,

maven { url 'https://kotlin.bintray.com/kotlinx/' }

There was na error but it compiled. I tested my app in real device for weeks and there wasn’t any issue running my app. My Room database is working fine.

like image 173
Rence Rei Avatar answered Nov 19 '22 19:11

Rence Rei


I solved this issue by downgrading to:

implementation 'androidx.room:room-runtime:2.1.0-alpha04'
annotationProcessor 'androidx.room:room-compiler:2.1.0-alpha04'
like image 38
Ahsan Avatar answered Nov 19 '22 19:11

Ahsan


Solved!

//Downgraded to alpha04.

implementation 'androidx.room:room-runtime:2.1.0-alpha04'
annotationProcessor 'androidx.room:room-compiler:2.1.0-alpha04'

// Other dependencies are..

implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha03'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.1.0-alpha03'
implementation 'androidx.lifecycle:lifecycle-livedata:2.1.0-alpha03'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.1.0-alpha03'

// Removed this from project level gradle.
maven { url "https://kotlin.bintray.com/kotlinx/" }

Don't forget to Clean & Rebuild the project after these changes

like image 3
Waheed Nazir Avatar answered Nov 19 '22 20:11

Waheed Nazir


Like most errors that have something to do with Room, the error message that pops up the most is most unlikely to be your problem. For me it helped to raise the max Error count by adding :

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xmaxerrs" << "1000"
    }
}

and then executing the gradle task:

 :app compileDebugJavaWithJavac

Then you will get a large list of errors, in your case the

Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@79d6c4df

But somewhere in that list are your real errors like a wrong query or something like that. Fix those errors and rebuild the project, that works most of the time, but sometimes you have to invalidate the cache and restart Android Studio.

like image 2
glm9637 Avatar answered Nov 19 '22 20:11

glm9637