Lottie 动画视图上的奇怪行为

所以我有一个带有 Lottie animationView 的启动画面,带有如下 xml 文件

但是 IDE 说

Cannot resolve class com.airbnb.lottie.LottieAnimationView

问题是我可以在调试和 Splash 内容中运行我的应用程序,完美地显示内容 当我想在发布版本中构建时它不能,因为错误:LottieAnimationView 必须扩展 android.view.View [Instantiatable]

我正在关注此处列出的官方文档 official lottie doc 没有任何问题,Splash 显示在调试版本中

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.airbnb.lottie.LottieAnimationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:lottie_autoPlay="true"
        app:lottie_rawRes="@raw/splash_cat"
        app:lottie_loop="true"
        app:lottie_speed="1.00" />

</androidx.constraintlayout.widget.ConstraintLayout>

edit1:我使用 flutter 并按照此示例 flutter Lottie Splash

yyy830ning 回答:Lottie 动画视图上的奇怪行为

试试这个

第一部分:

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="match_parent">

        <com.airbnb.lottie.LottieAnimationView
            android:id="@+id/progressAnimationView"
            android:layout_width="270dp"
            android:layout_height="196dp"
            android:layout_centerInParent="true"
            android:layout_marginTop="80dp"
            android:padding="5dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.553"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:lottie_autoPlay="true"
            app:lottie_fileName="splash_cat.json"    
            app:lottie_loop="true" />


      </androidx.constraintlayout.widget.ConstraintLayout>

第二部分: 现在在程序代码部分,您可以通过这种方式再次看到您的动画文件的地址

IN 主活动

        private LottieAnimationView lottieAnimationView;  //global define 
        .
        .
        .

在 onCreate() //Activity 或 onCreateView Fragment

        lottieAnimationView = findViewById(R.id.progressAnimationView);
        lottieAnimationView.setAnimation(R.raw.splash_cat);
,

我遇到过这种情况,我所做的是重新实现最新的lottie版本和gradle,然后清理项目并重建项目。

本文链接:https://www.f2er.com/6714.html

大家都在问