在 Android 架构组件 1.1.1 中找不到 class DiffCallback:
Cant find class DiffCallback in Android Architecture component 1.1.1:
最近我在 gradle 文件
中更新了 android.arch 支持库版本
// ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.1"
// alternatively, just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.1"
// alternatively, just LiveData
implementation "android.arch.lifecycle:livedata:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
// Room (use 1.1.0-alpha1 for latest alpha)
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
// Paging
implementation "android.arch.paging:runtime:1.0.0-alpha7"
现在我说收到这个错误
不确定您之前使用的是哪个版本,但来自 changelog ( 1.0.0-alpha6, February 27, 2018)、
Classes renamed, and moved to recyclerview-v7:
- DiffCallback -> DiffUtil.ItemCallback
使用 DiffUtil.ItemCallback
class:
public static final DiffUtil.ItemCallback<User> DIFF_CALLBACK =
new DiffUtil.ItemCallback<User>() {
@Override
public boolean areItemsTheSame(
@NonNull User oldUser, @NonNull User newUser) {
//..
}
@Override
public boolean areContentsTheSame(
@NonNull User oldUser, @NonNull User newUser) {
//..
}
}
您还可以检查DiffCallback
class。现在这个 class 移到了 recyclerview-v7
中并且 已弃用 。
最近我在 gradle 文件
中更新了 android.arch 支持库版本 // ViewModel and LiveData
implementation "android.arch.lifecycle:extensions:1.1.1"
// alternatively, just ViewModel
implementation "android.arch.lifecycle:viewmodel:1.1.1"
// alternatively, just LiveData
implementation "android.arch.lifecycle:livedata:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
// Room (use 1.1.0-alpha1 for latest alpha)
implementation "android.arch.persistence.room:runtime:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
// Paging
implementation "android.arch.paging:runtime:1.0.0-alpha7"
现在我说收到这个错误
不确定您之前使用的是哪个版本,但来自 changelog ( 1.0.0-alpha6, February 27, 2018)、
Classes renamed, and moved to recyclerview-v7:
- DiffCallback -> DiffUtil.ItemCallback
使用 DiffUtil.ItemCallback
class:
public static final DiffUtil.ItemCallback<User> DIFF_CALLBACK =
new DiffUtil.ItemCallback<User>() {
@Override
public boolean areItemsTheSame(
@NonNull User oldUser, @NonNull User newUser) {
//..
}
@Override
public boolean areContentsTheSame(
@NonNull User oldUser, @NonNull User newUser) {
//..
}
}
您还可以检查DiffCallback
class。现在这个 class 移到了 recyclerview-v7
中并且 已弃用 。