【发布时间】:2021-04-08 21:54:41
【问题描述】:
我在运行我的应用程序时出错,我的主应用程序不是我的转换器。我不知道该怎么做才能修复它,有人可以帮助我吗?
日志错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.pokedex, PID: 22909
java.lang.NullPointerException: Parameter specified as non-null is null: method
kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter value
at com.example.pokedex.Converters.fromAbilityPokemonList(Unknown Source:2)
at com.example.pokedex.dao.PokemonDAO_Impl$1.bind(PokemonDAO_Impl.java:62)
at com.example.pokedex.dao.PokemonDAO_Impl$1.bind(PokemonDAO_Impl.java:36)
at androidx.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.java:63)
at com.example.pokedex.dao.PokemonDAO_Impl$2.call(PokemonDAO_Impl.java:84)
at com.example.pokedex.dao.PokemonDAO_Impl$2.call(PokemonDAO_Impl.java:79)
at androidx.room.CoroutinesRoom$Companion$execute$2.invokeSuspend(CoroutinesRoom.kt:54)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at androidx.room.TransactionExecutor$1.run(TransactionExecutor.java:45)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
类转换器
class Converters {
// Conversor PokemonAbility
@TypeConverter
fun fromAbilityPokemonList(value: List<PokemonAbility>): String {
val gson = Gson()
val type = object : TypeToken<List<PokemonAbility>>() {}.type
return gson.toJson(value, type)
}
@TypeConverter
fun toAbilityPokemonList(value: String): List<PokemonAbility> {
val gson = Gson()
val type = object : TypeToken<List<PokemonAbility>>() {}.type
return gson.fromJson(value, type)
}
// Conversor Type Pokemon
@TypeConverter
fun fromTypePokemonList(value: List<String>): String {
val gson = Gson()
val type = object : TypeToken<List<String>>() {}.type
return gson.toJson(value, type)
}
@TypeConverter
fun toTypePokemonList(value: String): List<String> {
val gson = Gson()
val type = object : TypeToken<List<String>>() {}.type
return gson.fromJson(value, type)
}
在我进行迁移以将“Not Null 更改为 TEXT my db data”后,此错误开始发生
【问题讨论】:
标签: android kotlin fatal-error