Realm does not support Kotlin ByteArray type (java byte[])
See original GitHub issueGoal
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:
- Created 5 years ago
- Comments:16 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same error after updating some library versions. These two caused it:
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.
I’ve got this after adding
Timber 4.7.1to the project This is the log: