Crash while using SNAPSHOT version with GSON
See original GitHub issueHello,
I’m trying to use the 0.11.0-SNAPSHOT
version of the SDK.
I can build and run the app, but when I try to deserialize some JSON data, I’ve got a crash.
If I use the non-snapshot version (0.10.2
), everything works perfectly.
I added my settings.gradle
, global build.gradle
& module build.gradle
files to show how I configured the snapshot version.
Did I do something wrong?
Stacktrace:
2022-04-28 09:03:23.291 E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-3
Process: com.test.realmkotlin, PID: 5675
java.lang.AssertionError: AssertionError (GSON 2.9.0): illegal type variable reference
at com.google.gson.Gson.fromJson(Gson.java:1008)
at com.google.gson.Gson.fromJson(Gson.java:956)
at com.google.gson.Gson.fromJson(Gson.java:905)
at com.test.realmkotlin.data.api.ApiRepository.getMailboxes(ApiRepository.kt:406)
at com.test.realmkotlin.data.cache.MailRealm.getMailboxes(MailRealm.kt:55)
at com.test.realmkotlin.ui.main.TestRealmViewModel.testRealm(TestRealmViewModel.kt:61)
at com.test.realmkotlin.ui.main.MainActivity$onCreate$1$1.invokeSuspend(MainActivity.kt:40)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: java.lang.AssertionError: illegal type variable reference
at libcore.reflect.TypeVariableImpl.resolve(TypeVariableImpl.java:111)
at libcore.reflect.TypeVariableImpl.getGenericDeclaration(TypeVariableImpl.java:125)
at libcore.reflect.TypeVariableImpl.hashCode(TypeVariableImpl.java:47)
at java.util.HashMap.hash(HashMap.java:338)
at java.util.HashMap.get(HashMap.java:556)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:353)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:396)
at com.google.gson.internal.$Gson$Types.resolve($Gson$Types.java:343)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:116)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:165)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.Gson.fromJson(Gson.java:990)
at com.google.gson.Gson.fromJson(Gson.java:956)
at com.google.gson.Gson.fromJson(Gson.java:905)
at com.test.realmkotlin.data.api.ApiRepository.getMailboxes(ApiRepository.kt:406)
at com.test.realmkotlin.data.cache.MailRealm.getMailboxes(MailRealm.kt:55)
at com.test.realmkotlin.ui.main.TestRealmViewModel.testRealm(TestRealmViewModel.kt:61)
at com.test.realmkotlin.ui.main.MainActivity$onCreate$1$1.invokeSuspend(MainActivity.kt:40)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } // Realm Kotlin SNAPSHOT
}
}
rootProject.name = 'realmkotlin'
include ':app'
Global build.gradle:
buildscript {
ext.gradle_version = '7.1.3'
ext.kotlin_version = '1.6.20'
ext.realm_kotlin_version = '0.11.0-SNAPSHOT' // Realm Kotlin SNAPSHOT
ext.navigation_version = '2.4.2'
ext.java_version = JavaVersion.VERSION_1_8
repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } } // Realm Kotlin SNAPSHOT
dependencies { classpath "io.realm.kotlin:gradle-plugin:$realm_kotlin_version" } // Realm Kotlin SNAPSHOT
}
plugins {
id 'com.android.application' version "$gradle_version" apply false
id 'com.android.library' version "$gradle_version" apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
}
task clean(type: Delete) { delete rootProject.buildDir }
Module build.gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
configurations.all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } // Realm Kotlin SNAPSHOT
apply plugin: "io.realm.kotlin" // Realm Kotlin SNAPSHOT
android {
compileSdk 32
defaultConfig {
applicationId 'com.test.realmkotlin'
minSdk 24
targetSdk 32
versionCode 1
versionName '1.0'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility rootProject.ext.java_version
targetCompatibility rootProject.ext.java_version
}
kotlinOptions { jvmTarget = rootProject.ext.java_version }
buildFeatures { viewBinding true }
}
dependencies {
implementation "io.realm.kotlin:library-base:$rootProject.ext.realm_kotlin_version" // Realm Kotlin SNAPSHOT
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Gson crash when apply proguard - Stack Overflow
Basically, your problem is that one of your classes is missing the field DESTROYED that was probably renamed by Proguard. Another option is...
Read more >[MC-226352] Game crashes with error: 1 (while launching) - Jira
Seriously, I'm the official launcher user and TLauncher user. I can't use latest snapshot cause dumbest error in code: crashes by reason "1"....
Read more >Getting crash in Android OS 7 · Issue #542 - GitHub
While in process of uploading file to OneDrive, we are getting crash on device OS 7. We couldn't verify this crash on Android...
Read more >My game crashes when trying to enter or edit a world : r/fabricmc
The game crashed whilst rendering screenError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT ...
Read more >(Solved) [1.8] Gson error - Modder Support - Forge Forums
Recently I've been using Gson but in the last days I had problems with Gson, ... public static final String VERSION = "0.1.0-SNAPSHOT"; ......
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 FreeTop 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
Top GitHub Comments
This should fix the issues:
I suspect GSON is having issues with our internal class, this one: https://github.com/realm/realm-kotlin/blob/master/packages/library-base/src/commonMain/kotlin/io/realm/internal/RealmObjectReference.kt#L44, but ignoring it should be perfectly fine.
I’ll make sure it gets added to our documentation.
Hi @KevinBoulongne Thanks for the hint, I’m taking a look.