android - api图像返回null
问题描述
我正在尝试获取我正在使用的 api 的图像,但它被返回 null 并且错误指向我的 Item.java
日志:
C:\Users\matheus.correa_est\Desktop\Pokedex-
master\app\build\tmp\kapt3\stubs\debug\com\example\pokedex\model\PokemonItem.java:16: error: Cannot
figure out how to save this field into database. You can consider adding a type converter for it.
private final com.example.pokedex.model.PokemonImage images = null;
^
> Task :app:kaptDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more
log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
26 actionable tasks: 2 executed, 24 up-to-date
错误在哪里拉(PokemonItem.java)
private final com.example.pokedex.model.PokemonImage images = null;
@org.jetbrains.annotations.NotNull()
类 PokemonItem
@Entity(tableName = "PokemonItem")
@TypeConverters(Converters::class)
data class PokemonItem(
@PrimaryKey(autoGenerate = false)
var id: String = "",
@SerializedName("name") val nome: String = "",
val images: PokemonImage,
val types: List<String>,
val abilities: List<PokemonAbility>,
val hp: String = ""
) : Serializable
宝可梦数据:
data class PokemonData(
val data: List<PokemonItem>
)
data class PokemonAbilities(
var ability: List<PokemonAbility>
)
data class PokemonAbility(
var name: String,
var text: String,
var type: String
): Serializable
data class PokemonImage(
@SerializedName("small") val smallImageUrl: String
)
由于这个错误,我的应用程序甚至没有打开,我也尝试为 Image 创建转换器,但我没有成功
解决方案
推荐阅读
- azure - 来自 AKS 群集内 pod 的 Internet 连接
- database-design - 这是用于文档跟踪的良好数据库设计实践吗?
- php - 无法使用子域 GoDaddy、AWS 和 Routes 部署 Laravel 5.2
- julia - 如何在 Julia 中分解一个数字?
- r - 具有聚集列的 ggplot2
- reactjs - 如何监视在 componentDidMount 内部调用的方法
- entity-framework-core - 如果添加到上下文中保存更改
- r - 如何查找列表中的列表数量
- mysql - 如何使用 EJS 将 Node.js 中的下拉值发布到 MySQL 数据库?
- javascript - 如何删除字符串中出现多次的字符