use ByteArray ( kotlin's byte[] alias) with Realm
example:
open class TestModel(
@RealmField(name = "test")
var test: ByteArray? = ByteArray(0)): RealmObject()
compiles fine
error: Field "test" of type "(@org.jetbrains.annotations.Nullable :: byte)[]" is not supported.
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;
}
Realm version(s): ?=5.5.0
Realm sync feature enabled: no
Android Studio version: 3.2
Which Android version and device: emulator 8.0
Have you tried ByteArray instead of ByteArray??
same thing:
open class TestModel(
@RealmField(name = "test")
var test: ByteArray = ByteArray(0)
): RealmObject()
gives java class:
@kotlin.Metadata(mv = {1, 1, 11}, bv = {1, 0, 2}, k = 1, d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0002\b\u0005\b\u0016\u0018\u00002\u00020\u0001B\u000f\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003\u00a2\u0006\u0002\u0010\u0004R\u001e\u0010\u0002\u001a\u00020\u00038\u0006@\u0006X\u0087\u000e\u00a2\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\u0004\u00a8\u0006\b"}, d2 = {"Lch/sherpany/boardroom/model/encryption/TestModel;", "Lio/realm/RealmObject;", "test", "", "([B)V", "getTest", "()[B", "setTest", "app_debug"})
public class TestModel extends io.realm.RealmObject {
@org.jetbrains.annotations.NotNull()
@io.realm.annotations.RealmField(name = "test")
private byte[] test;
@org.jetbrains.annotations.NotNull()
public final byte[] getTest() {
return null;
}
public final void setTest(@org.jetbrains.annotations.NotNull()
byte[] p0) {
}
public TestModel(@org.jetbrains.annotations.NotNull()
byte[] test) {
super();
}
public TestModel() {
super();
}
}
I think that annotation @org.jetbrains.annotations.NotNull() could be a problem
I've done little research and:
Constants.JAVA_TO_REALM_TYPES has "byte[]" (string) as Type. Then it's used to check supported field types in RealmProxyClassGenerator.emitPersistedFieldAccessors where field.asType().toString()= fieldTypeCanonicalName should be byte[]but it is (@org.jetbrains.annotations.NotNull :: byte)[]
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.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.
Maybe this is related?
https://github.com/JakeWharton/timber/issues/295
Changing the nullable import from
import org.jetbrains.annotations.Nullable; to import android.support.annotation.Nullable;
Fixed the build for me. But i'm not sure what changes with this...
I've got this after adding
Timber 4.7.1to the project
This is the log:Equipment.java:18: error: Field "workCenterCode" of type "(@org.jetbrains.annotations.Nullable :: java.lang.String)" is not supported.
Same here, issue appeared after updating Timber to 4.7.1
Having the same issue with Timber 4.7.1...anyone found the solution..?
It seems to be the only solution now is to downgrade Timber to 4.5.0
Most helpful comment
I've got this after adding
Timber 4.7.1to the projectThis is the log: