Reputation: 1015
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
Upvotes: 15
Views: 11859
Reputation: 21
I just change this line in gradle-wrapper.properties
:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
Upvotes: 0
Reputation: 1200
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.
Upvotes: -1
Reputation: 744
I solved it by updating
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"
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"
Upvotes: 0
Reputation: 1015
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
Upvotes: 48
Reputation: 7
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.
Upvotes: 0
Reputation: 1621
implementation "androidx.concurrent:concurrent-futures:1.1.0"
Reference: https://developer.android.com/jetpack/androidx/releases/concurrent
Upvotes: 6