airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
35.03k stars 5.41k forks source link

[compose] Class not found MutableState - Runtime Crash #1752

Closed CaptnBlubber closed 3 years ago

CaptnBlubber commented 3 years ago

When following the documentation and fetching the latest snapshot from sonatype the app will crash when using beta-01 versions of compose with a Class not found exception:

 java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/runtime/MutableStateKt;

I already did some investigations and it seems like although the code already is updated in github the snapshot is not properly pushed.

Here is the output form ./gradlew dependencies:

--- com.airbnb.android:lottie-compose:1.0.0-alpha06-SNAPSHOT
|    +--- com.airbnb.android:lottie:3.6.1-SNAPSHOT
|    |    +--- androidx.appcompat:appcompat:1.0.0 -> 1.3.0-beta01 (*)
|    |    \--- com.squareup.okio:okio:1.17.4 -> 2.9.0 (*)
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.4.30 (*)
|    +--- androidx.compose.foundation:foundation:1.0.0-alpha12 -> 1.0.0-beta01 (*)
|    \--- androidx.compose.ui:ui:1.0.0-alpha12 -> 1.0.0-beta01 (*)

My current workaround: I have cloned the repository and included a selfcompiled .aar for now.

jossiwolf commented 3 years ago

Adding some info here, it looks like the latest commit isn't available as a snapshot on Sonatype. I'm guessing the snapshot that's included here still uses Compose Alpha 11 or 12. Either manual deployment is needed or we fix deployment from CI.

gpeal commented 3 years ago

Hmm, it looks like something funky happened with the deploy action. I'll take a look https://github.com/airbnb/lottie-android/runs/1973198319

gpeal commented 3 years ago

I just manually pushed a new snapshot

ericktijerou commented 3 years ago

I've updated to 1.0.0-alpha07-SNAPSHOT and everything works well with compose 1.0.0-beta01.

CaptnBlubber commented 3 years ago

Working marvelous! I guess the issue can be closed :)

peterfortuin commented 3 years ago

Where can I download this 1.0.0-alpha07-SNAPSHOT?

jossiwolf commented 3 years ago

@peterfortuin Please follow the docs at http://airbnb.io/lottie/#/android-compose for that :) You'll need to add the Sonatype snapshot repository to your repositories.

peterfortuin commented 3 years ago

@jossiwolf Thanks for the fast response. I got it to work.

nathan-castlehow commented 3 years ago

Sorry for hijacking this issue, wasn't sure the best place to get in touch but is anyone having issues grabbing the snapshot? I'm trying to update to the snapshot due to the runtime issue above but i can never get it to resolve. I've added the snapshot repository and the package and just get the standard failed to resolve error.

I presume I am missing something obvious, is there a way to browse the snapshot repository to see what is available? Am i trying to grab the right package?

Failed to resolve: com.airbnb.android:lottie-compose:1.0.0-alpha07-SNAPSHOT

Thanks!

jossiwolf commented 3 years ago

@nathan-castlehow You can browse the snapshot repo at oss.sonatype.org :) The latest version is definitely there and I can pull it.

Can you show us how you added the repository and the dependency?

nathan-castlehow commented 3 years ago

Hmm weird. Thanks so much for getting back to me @jossiwolf . That link is also super helpful! :)

The gradle files are using the gradle dsl.

So in my top level gradle build file I have added maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } to the repositories.

In my app level gradle file I have implementation "com.airbnb.android:lottie-compose:1.0.0-alpha07-SNAPSHOT"

I presume I am missing something obvious (like something wrong with some syntax somewhere)

jossiwolf commented 3 years ago

That's definitely odd! This should all be correct - have you added the repo declaration to the allprojects or subprojects block (assuming you have a standard setup)?

// Top-level buildscript
allprojects {
    repositories {
        ...
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
}
nathan-castlehow commented 3 years ago

I had added it to the repositories in the build script block instead of the all projects block :man_facepalming:

Thanks so much for seeing that one through with me @jossiwolf . Very much appreciated!

itsReward commented 1 year ago

This error typically occurs when the required class or dependency is not present in the classpath. In your case, it seems that the Landroidx/compose/runtime/MutableStateKt class is missing from the classpath.

To resolve this issue, make sure you have the necessary dependencies and libraries configured correctly in your project. Specifically, ensure that you have the required version of the Android Compose library (androidx.compose.runtime) available and properly linked to your project.

Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Check your project dependencies: Verify that the required Android Compose libraries are correctly specified in your project's build file (e.g., build.gradle or build.gradle.kts). Ensure you have the necessary dependencies and that they are up to date.
  2. Refresh dependencies: In IntelliJ IDEA, you can try refreshing your project dependencies by clicking the "Refresh" button in the Gradle tool window. This action will update your project's dependencies according to the specified configurations.
  3. Clean and rebuild: Perform a clean build of your project to ensure that all the necessary files are generated and compiled correctly. In IntelliJ IDEA, you can choose the "Build" -> "Clean Project" option, followed by "Build" -> "Rebuild Project" to initiate a clean build process.
  4. Check for conflicting dependencies: It's possible that there may be conflicting dependencies or version mismatches causing the issue. Review your project's dependencies and check for any conflicts or inconsistencies. You can use tools like gradle-dependency-analyze or IntelliJ IDEA's built-in dependency analysis to identify and resolve any conflicts.

Double-checking your project configuration, dependencies, and ensuring that the necessary libraries are correctly specified and available should help resolve the NoClassDefFoundError related to androidx.compose.runtime.MutableState.