找不到 com.google.common.util.concurrent.ListenableFuture 的 Android Studio 类文件

ria*_*ial 1 java android android-workmanager

我无法构建我的项目,因为它失败了,因为它找不到类。我的 SDK 或依赖项有问题吗?

我试过使缓存无效并重新启动。我正在使用 api 29。

以下是错误出现的地方

public class PodcastUpdateWorker extends Worker {

}
Run Code Online (Sandbox Code Playgroud)

这是错误打印输出

/home/snowman/AndroidStudioProjects/CorbettReportPodcasts/app/src/main/java/com/example/corbettreportpodcasts/PodcastUpdateWorker.java:36: error: cannot access ListenableFuture
public class PodcastUpdateWorker extends Worker {
       ^
  class file for com.google.common.util.concurrent.ListenableFuture not found
Run Code Online (Sandbox Code Playgroud)

和我的依赖

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'com.google.android.exoplayer:exoplayer-core:2.12.0'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.0'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
    implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
    implementation "androidx.room:room-runtime:2.2.5"
    annotationProcessor "androidx.room:room-compiler:2.2.5"
    testImplementation "androidx.room:room-testing:2.2.5"
    implementation 'androidx.work:work-runtime:2.4.0'
    implementation 'com.google.android.material:material:1.2.1'
}
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏

ria*_*ial 10

exoplayer 库存在与 listenablefuture 冲突的问题,导致无法找到它。阅读更多

你可以包括番石榴implementation 'com.google.guava:guava:29.0-android'来解决这个问题


Che*_*wal 5

implementation "androidx.concurrent:concurrent-futures:1.1.0"
Run Code Online (Sandbox Code Playgroud)

参考:https : //developer.android.com/jetpack/androidx/releases/concurrent

  • 不适合我。我相信这是项目配置问题,但我不能确定 (3认同)