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.05k stars 5.41k forks source link

Can't access to the functions of lottie-compose #1882

Closed barbozabarb closed 3 years ago

barbozabarb commented 3 years ago

Hello ! I added to my dependencies the implementation of lottie for lottie-compose


  implementation "com.airbnb.android:lottie:4.1.0"
   implementation "com.airbnb.android:lottie-compose:4.1.0"

Also added to the repositories, I think is tha latest stable SNAPHOT maven { url "https://oss.sonatype.org/content/repositories/snapshots/v4.1.1-SNAPSHOT" }

Then when I code in any kt file it seem to be no problem, but when I run the app I recieve the following error

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.perri, PID: 8141 java.lang.NoSuchMethodError: No static method rememberLottieComposition$default(Lcom/airbnb/lottie/compose/LottieCompositionSpec;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lcom/airbnb/lottie/compose/LottieCompositionResult; in class Lcom/airbnb/lottie/compose/RememberLottieCompositionKt; or its super classes (declaration of 'com.airbnb.lottie.compose.RememberLottieCompositionKt' appears in /data/app/com.example.perri-4S0vAHOU272w9LsxnGCv4A==/base.apk) at com.example.perri.LottieAnimation.AnimationADktKt.(AnimationADkt.kt:9) at com.example.perri.LottieAnimation.AnimationADktKt.getComposition3(AnimationADkt.kt:9) at com.example.perri.LottieAnimation.AnimationADkt.GetNewValues(AnimationADkt.kt:14) at com.example.perri.MainActivity.onCreate(MainActivity.kt:53) at android.app.Activity.performCreate(Activity.java:7835) at android.app.Activity.performCreate(Activity.java:7824) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3300) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3464) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2065) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7631) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964) I/Process: Sending signal. PID: 8141 SIG: 9

So the thing, is that the imports are detected and seems to be ok

import com.airbnb.lottie.compose.LottieCompositionSpec import com.airbnb.lottie.compose.rememberLottieComposition import androidx.compose.runtime.getValue

but when i check out the Gradle: com.airbnb.android:lottie-compose:4.1.0@aar files

Found some items that look kinda suspicious to me Some files including RememberLottieCompositionKt.class, got this extension of "class" and inside this files i get this message

// IntelliJ API Decompiler stub source generated from a class file // Implementation of methods is not available

How do I should procced to solve this ?

Thank you in advance !

gpeal commented 3 years ago

Can you attach a repro project?

barbozabarb commented 3 years ago

Can't attach the file to the comment via zip, it says "is not included in the list". But i uploaded to mega

https://mega.nz/file/AhEFHCST#qTNUWXUwXjM2KwQ6Egzo9mMdUV75R5myeUWnAgWdQdQ

It is a little messy because it is the project where I do the tests. I ordered it so that the problem is seen most directly

But if you want I can put it into a github file

gpeal commented 3 years ago

@barbozabarb Your project has tons and tons of outdated dependencies that aren't compatible with Compose. 1) Make sure you're on Android Studio Arctic Fox or later 1) Upgrade Gradle to 7.2 (gradle-wrapper.properties) 2) Upgrade the Android Gradle Plugin to 7.0.1 (classpath 'com.android.tools.build:gradle:7.0.1' in build.gradle) 3) Go to Settings -> Build, Execution, and Deployment -> Gradle and change the jdk to the embedded one 4) Change the kotlin version to 1.5.21 (from 1.5.10)

You might want to walk through some Compose tutorials as well. AnimationADkt uses some of the new Composable APIs but isn't called from a Composable. It's worth getting comfortable with Jetpack Compose before adding Lottie.

barbozabarb commented 3 years ago

Thank you very much for your steps Gabriel. I've followed and now its working ! Also I'll follow your advice and learn more about JetpackCompose