Kotlin Can';t在释放模式下反序列化Gson对象
在我将Gradle从版本4升级到版本5之前,一切都在调试和发布模式下工作Kotlin Can';t在释放模式下反序列化Gson对象,kotlin,gson,retrofit,Kotlin,Gson,Retrofit,在我将Gradle从版本4升级到版本5之前,一切都在调试和发布模式下工作 buildscript { repositories { google() jcenter() mavenCentral() maven { url 'https://plugins.gradle.org/m2/' } } dependencies { // classpath 'com.gradle:build-sc
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
// classpath 'com.gradle:build-scan-plugin:1.16'
// classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.gradle:build-scan-plugin:2.0'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'io.realm:realm-gradle-plugin:5.9.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$Deps.KOTLIN_VERSION"
}
}
apply plugin: 'com.gradle.build-scan'
梯度包装
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
//distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
现在我有一个不能反序列化的对象
import com.google.gson.annotations.SerializedName
class EntityPost {
@field:SerializedName("id") var id: String = ""
@field:SerializedName("description") val description: String? = null
@field:SerializedName("resource") val media: EntityMedia? = null
...
}
仅在发布模式下,对于嵌套对象EntityMedia,其本身或其属性为null,而其他属性则可以
class EntityMedia {
@SerializedName("id") val resourceId: String? = null
@SerializedName("contentType") val contentType: String? = null
}
我使用的是RxJava2
implementation "com.squareup.retrofit2:converter-gson:2.5.0"
如果我将媒体变量强制转换为Any,结果是
{id=5612a7c54, contentType=video/mp4}
您添加了proguard规则了吗?你。。。是伟大的您添加了proguard规则了吗?你。。。是伟大的