Reputation: 37569
I'm getting this runtime exception when obfuscating with proguard:
Exception in thread "DefaultDispatcher-worker-2" com.fasterxml.jackson.c.a.S: Instantiation of [simple type, class com.myapp.data.datasource.network.model.Linea] value failed for JSON property p0 due to missing (therefore NULL) value for creator parameter p0 which is a non-nullable type
at [Source: (okio.RealBufferedSource$inputStream$1); line: 10, column: 1] (through reference chain: java.util.ArrayList[0]->com.myapp.data.datasource.network.model.Linea["p0"])
at com.fasterxml.jackson.c.a.O.createFromObjectWith(Unknown Source)
at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(Unknown Source)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(Unknown Source)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(Unknown Source)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(Unknown Source)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(Unknown Source)
at com.fasterxml.jackson.dataformat.xml.deser.WrapperHandlingDeserializer.deserialize(Unknown Source)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(Unknown Source)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(Unknown Source)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(Unknown Source)
at com.fasterxml.jackson.dataformat.xml.deser.XmlDeserializationContext.readRootValue(Unknown Source)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(Unknown Source)
at com.fasterxml.jackson.databind.ObjectReader.readValue(Unknown Source)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(Unknown Source)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(Unknown Source)
at retrofit2.OkHttpCall.parseResponse(Unknown Source)
at retrofit2.OkHttpCall$1.onResponse(Unknown Source)
at okhttp3.internal.connection.RealCall$AsyncCall.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@32d010be, Dispatchers.IO]
I don't have any property p0
inside Linea, this is being caused by Proguard, if I disable it it works.
This is the Linea class inside that package:
data class Linea(
val idLinea: String,
val nameLinea: String
)
I tryed to solve it adding this rule:
-keep class com.myapp.data.datasource.network.model.** { *; }
Nothing changes, the error is the same, so I tryed with this:
-keep class com.** { *; }
Nothing happens too. Same error.
Am I doing something wrong with that keep? is not this way how you keep classes in proguard config?
Upvotes: 1
Views: 52
Reputation: 478
try to start by adding this -dontobfuscate to proguard file and just see if it will workd what it will do is just not obfuscating names but the code will still be optimized but it is not ideal just use it for debbuging .
also try adding @SerializedName("idLinea")and @SerializedName("nameLinea") which should prevent the varaible's name's from being changed in the serialization.
take a look at this article android proguard and serialization
Upvotes: 0