Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Android Studio class file for com.google.common.util.concurrent.ListenableFuture not found

Ask Question

I cannot build my project due to it failing because it cannot find a class. Is there something wrong with my sdk or dependancies?

I have tried invalidating cache and restarting. I am using api 29.

The following is where the error shows up

public class PodcastUpdateWorker extends Worker {

Here is the error printout

/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

and my dependancies

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'

any help is appreciated

There is an issue with the exoplayer library conflicting with listenablefuture causing it not to be found. Read Here – rial Oct 10, 2020 at 20:28

There is an issue with the exoplayer library conflicting with listenablefuture causing it not to be found. READ MORE

you can include guava implementation 'com.google.guava:guava:29.0-android' to fix this

Thanks. Tricky thing. I wonder, how to find out resolutions for such problems on one's own... – sberezin Apr 15, 2022 at 19:45 Don't be disheartened, I usually check the mailing lists or repository issues for the package in question if I run into a problem. At the time I answered this I had only been learning Android for 2 months. – rial Jul 16, 2022 at 18:12

Check for the package name in gradle scripts (module:app) and in ...app>src>main>java.

Rename the folder to the desired package name. Make sure that the package name is changed in all the java files also. After renaming, sync your project with gradle files.

If you are doing this after the first Gradle sync, then this trick may not work. You need to change them manually.

I incorrectly tried to change the project name in the question i asked. Sorry. The question has been updated – rial Oct 10, 2020 at 19:49
 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" 
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

also update these to latest versions, if applicable

api 'androidx.core:core-ktx:1.3.2' 
api "org.jetbrains.kotlin:kotlin-stdlib:1.4.32"

In addition to the accepted answer. I didn't user Exoplayer in the application. After digging deeper I found that if you use Google's library for guava to fix conflicts like this:

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

This will also cause an issue. Removing this dependency solved the problem. BUT on the other hand, if you use some library, which causes the problem with listenablefeature in opposite adding this dependency solves the problem.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.