如何解决找不到com.google.common.util.concurrent.ListenableFuture的Android Studio类文件
由于无法找到项目,我无法建立我的项目。我的SDK或相依性有问题吗?
我尝试使缓存无效并重新启动。我正在使用API 29。
以下是显示错误的地方
public class PodcastUpdateWorker extends Worker {
}
这是错误的打印输出
/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
和我的依赖
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'
}
感谢您的帮助
解决方法
implementation "androidx.concurrent:concurrent-futures:1.1.0"
参考:https://developer.android.com/jetpack/androidx/releases/concurrent
,exoplayer库存在一个与listenablefuture冲突的问题,导致找不到该库。 READ MORE
您可以加入番石榴implementation 'com.google.guava:guava:29.0-android'
来解决此问题
在gradle脚本(module:app)和...app>src>main>java
中检查包名称。
将文件夹重命名为所需的软件包名称。确保在所有java文件中也更改了包名称。重命名后,将您的项目与Gradle文件同步。
如果您是在第一次Gradle同步后执行此操作,则此技巧可能不起作用。您需要手动更改它们。
,我通过更新解决了
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
to
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
如果适用,也将这些更新到最新版本
api 'androidx.core:core-ktx:1.3.2'
api "org.jetbrains.kotlin:kotlin-stdlib:1.4.32"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。