致命异常主要错误空指针异常
Fatal Exception Main error Null Pointer Exception
当 运行 我的应用程序认为主要的不是我的转换器时,我出错了。我不知道如何修复它,有人可以帮助我吗?
日志错误:
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.bind(PokemonDAO_Impl.java:62)
at com.example.pokedex.dao.PokemonDAO_Impl.bind(PokemonDAO_Impl.java:36)
at androidx.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.java:63)
at com.example.pokedex.dao.PokemonDAO_Impl.call(PokemonDAO_Impl.java:84)
at com.example.pokedex.dao.PokemonDAO_Impl.call(PokemonDAO_Impl.java:79)
at androidx.room.CoroutinesRoom$Companion$execute.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.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 转换器
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 我的数据库数据”后开始出现此错误
您正在接收值:在 fromAbilityPokemonList 中列出 null。而是使用 List?
@TypeConverter
fun fromAbilityPokemonList(value: List<PokemonAbility>?): String {
val gson = Gson()
val type = object : TypeToken<List<PokemonAbility>>() {}.type
return gson.toJson(value ?: ArrayList<PokemonAbility>(), type)
}
当 运行 我的应用程序认为主要的不是我的转换器时,我出错了。我不知道如何修复它,有人可以帮助我吗?
日志错误:
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.bind(PokemonDAO_Impl.java:62)
at com.example.pokedex.dao.PokemonDAO_Impl.bind(PokemonDAO_Impl.java:36)
at androidx.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.java:63)
at com.example.pokedex.dao.PokemonDAO_Impl.call(PokemonDAO_Impl.java:84)
at com.example.pokedex.dao.PokemonDAO_Impl.call(PokemonDAO_Impl.java:79)
at androidx.room.CoroutinesRoom$Companion$execute.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.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 转换器
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 我的数据库数据”后开始出现此错误
您正在接收值:在 fromAbilityPokemonList 中列出 null。而是使用 List?
@TypeConverter
fun fromAbilityPokemonList(value: List<PokemonAbility>?): String {
val gson = Gson()
val type = object : TypeToken<List<PokemonAbility>>() {}.type
return gson.toJson(value ?: ArrayList<PokemonAbility>(), type)
}