skydoves / Balloon

:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
https://skydoves.github.io/libraries/balloon/html/balloon/com.skydoves.balloon/index.html
Apache License 2.0
3.66k stars 284 forks source link

New project, getting `Cannot access 'androidx.lifecycle.FullLifecycleObserver' which is a supertype of 'com.skydoves.balloon.Balloon'. Check your module classpath for missing or conflicting dependencies` error #450

Closed phazei closed 1 year ago

phazei commented 1 year ago

Please complete the following information:

Describe the Bug:

balloon = Balloon.Builder(context)
    .setLayout(R.layout.chat_node_floating_menu)
    .setWidth(BalloonSizeSpec.WRAP)
    .setHeight(BalloonSizeSpec.WRAP)
    .setBalloonAnimation(BalloonAnimation.FADE)
    .setDismissWhenClicked(false)
    .build()
val popupView = balloon.getContentView()

the Builder is just fine, but every single balloon.xxx gives the same error:

Cannot access 'androidx.lifecycle.FullLifecycleObserver' which is a supertype of 'com.skydoves.balloon.Balloon'. Check your module classpath for missing or conflicting dependencies

This is my build gradle: ext.lifecycle_version = '2.5.1'

implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "com.github.skydoves:balloon:1.5.3"

I'm running Kotlin 1.8.0 on Android Studio Flamingo 2022.2.1

The thing is, it does still compile, and it sort of works, but my controller is full of errors

skydoves commented 1 year ago

Hey @phazei, balloon uses lifecycle version 2.6.1, so you need to update the version or exclude only the lifecycle dependency from the balloon like the below:


implementation ("com.github.skydoves:balloon:$balloonVersion") {
    exclude group: "androidx.lifecycle"
}
phazei commented 1 year ago

I initially was using 2.6.1, but I saw the closed ticket saying it wasn't supported. But I do get the same issue with both cases.

skydoves commented 1 year ago

This is weird. Balloon does not depend on FullLifecycleObserver since it moved to lifecycle 2.6.x. Check out: https://github.com/skydoves/Balloon/issues/419

You may need to clean your cache and sync gradle properly before running your project.

skydoves commented 1 year ago

I will close this issue for now. Please let me know if you still face this issue. Thanks!

CSHawley commented 1 year ago

@skydoves I'm also dealing with a similar issue since upgrading my project to 2.6.x. My app builds and runs despite the warning and invalidating caches does not clear errors.

From a glance, I noticed inheritance is FullLifecycleObserver -> DefaultLifecycleObserver -> Balloon. DefaultLifecycleObserver was converted to Kotlin in 2.6.0, while Balloon 1.5.3 still depends on lifecycle-common-2.5.1. My guess is both the Kotlin and Java versions of the class are still discoverable, but IntelliJ inspections cannot reflect this accurately.

It's strange that using exclude does not resolve the error. I also tried to force the latest version of the lifecycle package transitively with no luck. It may again be related to those two separate classes. I would think upgrading to the latest version of lifecycle-common in Balloon would resolve this issue.

skydoves commented 1 year ago

@CSHawley Thanks for your investigation. I feel like this issue comes from the androidx-fragment library, which still uses lifecycle 2.5.1. Let me update androidx libraries in the next release. Thanks!

nguyenhung111 commented 9 months ago

i had the same problem. by invalidate cache or clean gradle, but nothing solves the problem. def lifecycleVersion = "2.5.1" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion") // custom pop_up implementation("com.github.skydoves:balloon:1.6.0") { exclude group: "androidx.lifecycle" } Please let me know the solution. thank you

skydoves commented 9 months ago

Hi @nguyenhung111, would you able to update your lifecycle library version to 2.6.2?

nguyenhung111 commented 9 months ago

Yes. I updated to 2.6.2 and ballon to 1.6.1. but it seems like the error still exists. Do I need to update hilt or dagger // dagger hilt implementation("com.google.dagger:hilt-android:2.44.2") kapt("com.google.dagger:hilt-android-compiler:2.44.2") kapt("androidx.hilt:hilt-navigation-fragment:1.0.0") kapt("androidx.hilt:hilt-compiler:1.0.0") //lifecycle viewmodel def lifecycleVersion = "2.6.2" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion") // custom pop_up implementation("com.github.skydoves:balloon:1.6.1") { exclude group: "androidx.lifecycle" }