Realm does not support Kotlin ByteArray type (java byte[])

See original GitHub issue

Goal

use ByteArray ( kotlin’s byte[] alias) with Realm

example: open class TestModel( @RealmField(name = "test") var test: ByteArray? = ByteArray(0)): RealmObject()

Expected Results

compiles fine

Actual Results

error: Field "test" of type "(@org.jetbrains.annotations.Nullable :: byte)[]" is not supported.

Code Sample

kotlin version which does not compile:
open class TestModel(
        @RealmField(name = "test")
        var test: ByteArray? = ByteArray(0)): RealmObject()`


java version which compile fine:
public class TestModel extends RealmObject {
    @RealmField(name = "test")
    public byte[] test;
}

Version of Realm and tooling

Realm version(s): ?=5.5.0

Realm sync feature enabled: no

Android Studio version: 3.2

Which Android version and device: emulator 8.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
cruxdynocommented, Dec 13, 2018

I had the same error after updating some library versions. These two caused it:

  • updating com.bluelinelabs:conductor & support from 2.1.4 to 2.1.5
  • or updating com.jakewharton.timber:timber:4.5.1 to 4.7.1

I tried with realm 4.1.1 and 5.8.0, but it didn’t help. conductor and timber were the problems for me. I assume this behavior is a bug in annotation processing from some other library or plugin, so your solution might be different than mine, but I suggest you check whether you updated any libraries.

2reactions
Grohdencommented, Jan 2, 2019

I’ve got this after adding Timber 4.7.1 to the project This is the log:

Equipment.java:18: error: Field "workCenterCode" of type "(@org.jetbrains.annotations.Nullable :: java.lang.String)" is not supported.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Saving Kotlin ByteArray into Realm - android - Stack Overflow
Try this : open class Test : RealmObject() { @PrimaryKey var id: String? = null var picture: ByteArray? = null }.
Read more >
Field Types - Java SDK — Realm - MongoDB
Realm Database supports the following field data types: Boolean or boolean. Integer or int. Short or short. Long or long. Byte or byte[]....
Read more >
[Solved]-Saving Kotlin ByteArray into Realm-kotlin
Try this : open class Test : RealmObject() { @PrimaryKey var id: String? = null var picture: ByteArray? = null }. Sahjad Ansari...
Read more >
ByteArray - Kotlin Programming Language
Returns an array of type UByteArray, which is a view of this array where each element is an unsigned reinterpretation of the corresponding...
Read more >
Convert Byte Arrays to Hex Strings in Kotlin - Baeldung
Learn a couple of approaches to convert ByteArrays into hexadecimal ... we can take advantage of the Kotlin or even Java standard libraries ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found