android - 无法在 Jetpack 示例应用中为 ViewPager 充气
问题描述
我克隆了 Sunflower 示例应用程序(https://github.com/googlesamples/android-sunflower)作为学习的基线结构(我显然是新人)。我想使用 ViewPager,它给出了以下运行时错误:
android.view.InflateException: Binary XML file line #9: Binary XML file line #9: Error inflating class android.support.v4.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.support.v4.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager" on path: DexPathList[[...
我已经尝试对我的 gradle 文件进行大量更改以根据搜索解决此问题,但没有找到任何可行的方法。以下是当前的依赖项:
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
kapt "androidx.room:room-compiler:$rootProject.roomVersion"
implementation "android.arch.navigation:navigation-fragment-ktx:$rootProject.navigationVersion"
implementation "android.arch.navigation:navigation-ui-ktx:$rootProject.navigationVersion"
implementation("android.arch.work:work-runtime-ktx:$rootProject.workVersion") {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
implementation "androidx.core:core-ktx:$rootProject.ktxVersion"
implementation "androidx.legacy:legacy-support-v4:$rootProject.supportLibraryVersion"
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.lifecycleVersion"
implementation "androidx.recyclerview:recyclerview:$rootProject.supportLibraryVersion"
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "com.google.android.material:material:$rootProject.supportLibraryVersion"
implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$rootProject.kotlinVersion"
谁能告诉帮助指出我错过了什么?谢谢。
解决方案
推荐阅读
- android - 动态更改 RecyclerView 项目边距
- r - 渲染“页面”时出现 Hugo 错误
- css - 在 React 中的 Material-ui 上覆盖 TableRow 悬停 CSS
- swift - 动态编程变量初始化
- javascript - 事件没有像我认为的那样冒泡
- python - 如何在 Python 3.5 中恢复文件下载?
- javascript - 检查数组的某些元素是否相等
- python - hackkerank 上的三胞胎计数错误
- javascript - 如何成为@media 的第一名?
- email - 使用 AppleScript 通过邮件规则创建带有电子邮件详细信息的文本文件