GithubHelp home page GithubHelp logo

aghajari / axrlottie Goto Github PK

View Code? Open in Web Editor NEW
143.0 7.0 26.0 22.11 MB

AXrLottie (Android) Renders animations and vectors exported in the bodymovin JSON format. (Using rLottie)

License: Apache License 2.0

Java 8.87% CMake 0.44% C 32.80% C++ 57.05% Assembly 0.84% Meson 0.01%
lottie rlottie lottie-android lottie-animation bodymovin

axrlottie's Introduction


AXrLottie Renders animations
and vectors exported in the bodymovin JSON format
GitHubReleases

LCoders | AmirHosseinAghajari
picker

Platform API Maven Central Join the chat at https://gitter.im/Aghajari/community

What is lottie?

Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with bodymovin, Sketch with Lottie Sketch Export, and from Haiku.

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. Since the animation is backed by > JSON they are extremely small in size but can be large in complexity!

What is rlottie?

rlottie is a platform independent standalone c++ library for rendering vector based animations and art in realtime.

What is AXrLottie?

AXrLottie includes rlottie into Android. Easy A!

Lottie Examples

Screenshot

Table of Contents

Changelogs

1.4.0 :

  • Updated to the latest version of rlottie (1 Oct, 2022)
  • #20 Fixed
  • #19 Fixed

Other versions changelog

Installation

AXrLottie is available in the mavenCentral(), so you just need to add it as a dependency (Module gradle)

Gradle

implementation 'io.github.aghajari:AXrLottie:1.4.0'

Maven

<dependency>
  <groupId>io.github.aghajari</groupId>
  <artifactId>AXrLottie</artifactId>
  <version>1.4.0</version>
  <type>pom</type>
</dependency>

Usage

Let's START! 😃

Install AXrLottie

First step, you should initialize AXrLottie

AXrLottie.init(this);

Basic Usage

Create an AXrLottieImageView in your layout.

<com.aghajari.rlottie.AXrLottieImageView
        android:id="@+id/lottie_view"
        android:layout_width="180dp"
        android:layout_height="180dp"
        android:layout_gravity="center"/>

Now you just need to load your lottie Animation

lottieView.setLottieDrawable(AXrLottieDrawable.fromAssets(this,fileName)
                .setSize(width,height)
                .build());
lottieView.playAnimation();

you can load lottie file from following sources :

  • File
  • JSON (String)
  • URL
  • Assets
  • Resource
  • InputStram

lottie will cache animations/files by default. you can disable cache in AXrLottieDrawable Builder

Output

Back to contents

LayerProperty

To update a property at runtime, you need 3 things:

  1. KeyPath
  2. AXrLottieProperty
  3. setLayerProperty(KeyPath, AXrLottieProperty)
lottieDrawable.setLayerProperty("**" /**KeyPath*/, AXrLottieProperty.fillColor(color) /**AXrLottieProperty*/);

Output

KeyPath

A KeyPath is used to target a specific content or a set of contents that will be updated. A KeyPath is specified by a list of strings that correspond to the hierarchy of After Effects contents in the original animation. KeyPaths can include the specific name of the contents or wildcards:

  • Wildcard *
    • Wildcards match any single content name in its position in the keypath.
  • Globstar **
    • Globstars match zero or more layers.

Keypath should contains object names separated by (.) and can handle globe(**) or wildchar(*).

  • To change the property of fill1 object in the layer1->group1->fill1 : KeyPath = layer1.group1.fill1
  • If all the property inside group1 needs to be changed : KeyPath = **.group1.**

Properties

  • FillColor
  • FillOpacity
  • StrokeColor
  • StrokeOpacity
  • StrokeWidth
  • TrAnchor
  • TrOpacity
  • TrPosition
  • TrRotation
  • TrScale

DynamicProperties

Since v1.0.6 you can set dynamic properties to a layer!

Example :

lottieDrawable.setLayerProperty("**" /**KeyPath*/,
        AXrLottieProperty.dynamicFillColor(new AXrLottieProperty.DynamicProperty<Integer>() {
            @Override
            public Integer getValue(int frame) {
                if (frame > 40)
                    return Color.RED;
                else
                    return Color.BLUE;
            }
        }));

Back to contents

Layers

AXrLottieLayerInfo contains Layer's name,type,inFrame and outFrame.

for (AXrLottieLayerInfo layerInfo : lottieDrawable.getLayers()) {
    Log.i("AXrLottie", layerInfo.toString());
}

Back to contents

Markers

Markers exported form AE are used to describe a segment of an animation {comment/tag , startFrame, endFrame} Marker can be use to divide a resource in to separate animations by tagging the segment with comment string , start frame and duration of that segment.

More...

AXrLottieMarker contains comment/tag, inFrame and outFrame.

for (AXrLottieMarker marker : lottieDrawable.getMarkers()) {
    Log.i("AXrLottie", marker.toString());
}

You can select a marker in AXrLottieDrawable and set start&end frame of the animation with an AXrLottieMarker :

lottieDrawable.selectMarker(MARKER);

Markers in a JSON:

"markers":[{"tm":IN_FRAME,"cm":"COMMENT","dr":DURATION},...]

Example :

"markers":[{"tm":0,"cm":"first","dr":69.33},{"tm":69.33,"cm":"second","dr":69.33},{"tm":138.66,"cm":"third","dr":67.33}]

Back to contents

Lottie2Gif

you can export lottie animations as a GIF! thanks to gif-h

AXrLottie2Gif.create(lottieDrawable)
                .setListener(new AXrLottie2Gif.Lottie2GifListener() {
                    long start;

                    @Override
                    public void onStarted() {
                        start = System.currentTimeMillis();
                    }

                    @Override
                    public void onProgress(int frame, int totalFrame) {
                        log("progress : " + frame + "/" + totalFrame);
                    }

                    @Override
                    public void onFinished() {
                        log("GIF created (" + (System.currentTimeMillis() - start) + "ms)\r\n" +
                                "Resolution : " + gifSize + "x" + gifSize + "\r\n" +
                                "Path : " + file.getAbsolutePath() + "\r\n" +
                                "File Size : " + (file.length() / 1024) + "kb");
                    }
                })
                .setBackgroundColor(Color.WHITE)
                .setOutputPath(file)
                .setSize(gifSize, gifSize)
                .setBackgroundTask(true)
                .setDithering(false)
                .setDestroyable(true)
                .build();

Output

lottie.gif has been exported by AXrLottie2Gif

Back to contents

Listeners

OnFrameChangedListener:

void onFrameChanged(AXrLottieDrawable drawable, int frame);
void onRepeat (int repeatedCount,boolean lastFrame);
void onStop();
void onStart();
void onRecycle();

OnFrameRenderListener:

void onUpdate(AXrLottieDrawable drawable, int frame, long timeDiff, boolean force);
Bitmap renderFrame(AXrLottieDrawable drawable, Bitmap bitmap, int frame);

Back to contents

NetworkFetcher

Simple way to load lottie from URL (SimpleNetworkFetcher) :

AXrLottieDrawable.fromURL(URL)
	.build()

AXrLottie has a default network fetching stack built on HttpURLConnection. However, if you would like to hook into your own network stack for performance, caching, or analytics, you may replace the internal stack with your own.

AXrLottie.setNetworkFetcher(OkHttpNetworkFetcher.create());

AXrLottieDrawable.fromURL(URL)
	.build()

Back to contents

FileExtension

FileExtension specifies which type of files can be used in lottie.

As default, AXrLottie supports JSON , ZIP (must have a json file) , GZIP (just like .tgs).

You can add more FileExtensions (such as .7z).

Example :

AXrLottie.addFileExtension(new SevenZipFileExtension());   
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;

public class SevenZipFileExtension extends AXrFileExtension {

    public SevenZipFileExtension() {
        super(".7z");
    }

    @Override
    public boolean canParseContent(String contentType) {
    	// check content-type
        return contentType.contains("application/x-7z-compressed");
    }

    @Override
    public File toFile(String cache, File input, boolean fromNetwork) throws IOException {
    	// read 7zip file and extract animation.
        SevenZFile sevenZFile = new SevenZFile(input);
        SevenZArchiveEntry entry = sevenZFile.getNextEntry();
        if (((List<SevenZArchiveEntry>) sevenZFile.getEntries()).size() > 1) {
            throw new IllegalArgumentException("7zip file must contains only one json file!");
        }
        File output = AXrLottie.getLottieCacheManager().getCachedFile(cache, JsonFileExtension.JSON, fromNetwork, false);
        if (entry != null) {
            FileOutputStream out = new FileOutputStream(output);
            byte[] content = new byte[(int) entry.getSize()];
            sevenZFile.read(content, 0, content.length);
            out.write(content);
            out.close();
        }
        sevenZFile.close();
        return output;
    }
}

Add Telegram Animated Stickers support :

AXrLottie.addFileExtension(new GZipFileExtension(".tgs"));

Back to contents

AXrLottieGlideDecoder is a Glide integration library for displaying AXrLottieDrawable.

Example :

Glide.with(this)
        .load(Uri.parse("file:///android_asset/loader.json"))
        .set(AXrLottieGlideOptions.ENABLED, true)
        .set(AXrLottieGlideOptions.NAME, "loader.json")
        .set(AXrLottieGlideOptions.NETWORK, false)
        .into(imageView);

Back to contents

AnimatedSticker - AXEmojiView

you can create AXrLottieImageView in AXEmojiView/StickerView using this code :

AXEmojiManager.setStickerViewCreatorListener(new StickerViewCreatorListener() {
    @Override
    public View onCreateStickerView(@NonNull Context context, @Nullable StickerCategory category, boolean isRecent) {
        return new AXrLottieImageView(context);
    }
    
    @Override
    public View onCreateCategoryView(@NonNull Context context) {
        return new AXrLottieImageView(context);
    }
});

add this just after AXEmojiManager.install

and you can load your animations in StickerProvider

  @Override
  public StickerLoader getLoader() {
        return new StickerLoader() {
            @Override
            public void onLoadSticker(View view, Sticker sticker) {
                if (view instanceof AXrLottieImageView && sticker instanceof AnimatedSticker) {
                    AXrLottieImageView lottieImageView = (AXrLottieImageView) view;
                    AnimatedSticker animatedSticker = (AnimatedSticker) sticker;
                    if (animatedSticker.drawable==null){
                        animatedSticker.drawable = Utils.createFromSticker(view.getContext(),animatedSticker,100);
                    }
                    lottieImageView.setLottieDrawable(animatedSticker.drawable);
                    lottieImageView.playAnimation();
                }
            }

            @Override
            public void onLoadStickerCategory(View view, StickerCategory stickerCategory, boolean selected) {
                if (view instanceof AXrLottieImageView) {
                    AXrLottieImageView lottieImageView = (AXrLottieImageView) view;
                    AnimatedSticker animatedSticker = (AnimatedSticker) stickerCategory.getCategoryData();
                    if (animatedSticker.drawable==null){
                        animatedSticker.drawable = Utils.createFromSticker(view.getContext(),animatedSticker,50);
                    }
                    lottieImageView.setLottieDrawable(animatedSticker.drawable);
                    //lottieImageView.playAnimation();
                }
            }
        };
  }

Output

Back to contents

AXrLottieEmoji

Preview

This sample appends lottie files as Emoji in TextView and EditText. Read More & Download Sample

Back to contents

Author

License

Copyright 2020 Amir Hossein Aghajari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



LCoders | AmirHosseinAghajari
Amir Hossein Aghajari • EmailGitHub

axrlottie's People

Contributors

aghajari avatar fourlastor avatar hantrungkien avatar liminiens avatar superfashi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

axrlottie's Issues

Crash when constructing AXrLottieDrawable

Hello, I'm seeing a crash (from analytics, I haven't been able to reproduce it myself yet) when initializing an AXrLottieDrawable:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.Handler.post(java.lang.Runnable)' on a null object reference
       at com.aghajari.rlottie.DispatchQueue.postRunnable(DispatchQueue.java:91)
       at com.aghajari.rlottie.DispatchQueue.postRunnable(DispatchQueue.java:81)
       at com.aghajari.rlottie.DispatchQueuePool.execute(DispatchQueuePool.java:94)
       at com.aghajari.rlottie.AXrLottieDrawable.scheduleNextGetFrame(AXrLottieDrawable.java:849)
       at com.aghajari.rlottie.AXrLottieDrawable.setAllowDecodeSingleFrame(AXrLottieDrawable.java:689)
       at com.aghajari.rlottie.AXrLottieDrawable.initFromJson(AXrLottieDrawable.java:491)
       at com.aghajari.rlottie.AXrLottieDrawable.<init>(AXrLottieDrawable.java:438)
       at com.aghajari.rlottie.AXrLottieDrawable$Builder.build(AXrLottieDrawable.java:1329)

After a bit of investigation, this seems to happen at this line of DispatchQueue.

I think the source of the NPE could be in the try/catch statement a few lines before, my guess is that syncLatch.await(); throws an InterruptedException before being released, which would lead to handler being null.

setAutoRepeat false not working, keeps repeating

Example reproduction code:

setLottieDrawable(
  AXrLottieDrawable.fromJson(jsonString, cacheKey)
      .setSize(decodeWidth, decodeHeight)
      .setAutoRepeat(false)
      .setSpeed(speed) // speed is set to 1.0f
      .build()
);

playAnimation();

Observation vs. Expectation

I expect the animation to only play once, and then stop. However, the animation keeps repeating.

Can not build package an lib for changing src?

Hello, good morning @Aghajari
I can not build your lib to AAR.
Please help me to build it to modify some code and improve.

I run this gradle script:

install {
    repositories.mavenInstaller {
        pom.project {
            packaging 'aar'
            groupId artifact.groupId
            artifactId artifact.id
            version artifact.version
            name artifact.id // pom.project.name must be same as bintray.pkg.name
            url artifact.siteUrl
            inceptionYear '2020' // HARDCODED
            licenses {
                license { // HARDCODED
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }
            scm {
                connection artifact.gitUrl
                developerConnection artifact.gitUrl
                url artifact.siteUrl
            }
        }
    }
}

My Error:

/Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/src/vector/vdrawhelper_neon.cpp:26: error: undefined reference to 'pixman_composite_over_n_8888_asm_neon'



Execution failed for task ':AXrLottie:externalNativeBuildRelease'.
> Build command failed.
  Error while executing process /Users/henry/Library/Android/sdk/cmake/3.10.2.4988404/bin/ninja with arguments {-C /Users/henry/Downloads/AXrLottie-master/AXrLottie/.cxx/cmake/release/armeabi-v7a jlottie jlz4 rlottie rlottie-image-loader rlottie2gif}
  ninja: Entering directory `/Users/henry/Downloads/AXrLottie-master/AXrLottie/.cxx/cmake/release/armeabi-v7a'
  [1/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdrawhelper_sse2.cpp.o
  [2/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/freetype/v_ft_math.cpp.o
  [3/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/freetype/v_ft_raster.cpp.o
  [4/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/freetype/v_ft_stroker.cpp.o
  [5/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdebug.cpp.o
  [6/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vrect.cpp.o
  [7/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdrawhelper_neon.cpp.o
  [8/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdrawhelper_common.cpp.o
  [9/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vbrush.cpp.o
  [10/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vpathmesure.cpp.o
  [11/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vpainter.cpp.o
  [12/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vbitmap.cpp.o
  [13/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/velapsedtimer.cpp.o
  [14/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vmatrix.cpp.o
  [15/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdasher.cpp.o
  [16/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottieproxymodel.cpp.o
  [17/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vinterpolator.cpp.o
  [18/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/varenaalloc.cpp.o
  [19/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vpath.cpp.o
  [20/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vrle.cpp.o
  [21/41] Building CXX object CMakeFiles/rlottie2gif.dir/gif/gif.cpp.o
  [22/41] Linking CXX shared library /Users/henry/Downloads/AXrLottie-master/AXrLottie/build/intermediates/cmake/release/obj/armeabi-v7a/librlottie2gif.so
  [23/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vbezier.cpp.o
  [24/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vimageloader.cpp.o
  [25/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdrawhelper.cpp.o
  [26/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vdrawable.cpp.o
  [27/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottiekeypath.cpp.o
  [28/41] Building CXX object CMakeFiles/rlottie.dir/src/vector/vraster.cpp.o
  [29/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottieitem_capi.cpp.o
  [30/41] Building CXX object CMakeFiles/jlottie.dir/lottie.cpp.o
  In file included from /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:14:
  In file included from /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/gif/gif.h:63:
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/gif/../lottie.h:8:1: warning: typedef requires a name [-Wmissing-declarations]
  typedef struct LottieWrapper{
  ^~~~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/gif/../lottie.h:13:1: warning: typedef requires a name [-Wmissing-declarations]
  typedef struct LottieInfo{
  ^~~~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:116:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:116:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:169:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:169:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:244:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || bitmap == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:244:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || bitmap == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:322:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:322:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:330:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:330:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:346:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:346:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:354:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:354:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:369:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:369:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:381:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:381:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:393:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:393:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:405:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:405:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:417:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:417:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:429:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:429:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:441:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:441:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:453:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:453:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:465:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:465:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:477:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL || layer == nullptr) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:477:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL || layer == nullptr) {
              ~~ ^~~~
                 0
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:493:13: warning: comparison between NULL and non-pointer ('jlong' (aka 'long long') and NULL) [-Wnull-arithmetic]
      if (ptr == NULL) {
          ~~~ ^  ~~~~
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/lottie.cpp:493:16: warning: implicit conversion of NULL constant to 'long long' [-Wnull-conversion]
      if (ptr == NULL) {
              ~~ ^~~~
                 0
  38 warnings generated.
  [31/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottieloader.cpp.o
  [32/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottiemodel.cpp.o
  [33/41] Building CXX object src/vector/stb/CMakeFiles/rlottie-image-loader.dir/stb_image.cpp.o
  [34/41] Linking CXX shared library /Users/henry/Downloads/AXrLottie-master/AXrLottie/build/intermediates/cmake/release/obj/armeabi-v7a/librlottie-image-loader.so
  [35/41] Building C object CMakeFiles/jlz4.dir/lz4/lz4.c.o
  [36/41] Linking C shared library /Users/henry/Downloads/AXrLottie-master/AXrLottie/build/intermediates/cmake/release/obj/armeabi-v7a/libjlz4.so
  [37/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottieanimation.cpp.o
  [38/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottieitem.cpp.o
  [39/41] Building CXX object CMakeFiles/rlottie.dir/src/lottie/lottieparser.cpp.o
  [40/41] Linking CXX shared library /Users/henry/Downloads/AXrLottie-master/AXrLottie/build/intermediates/cmake/release/obj/armeabi-v7a/librlottie.so
  FAILED: /Users/henry/Downloads/AXrLottie-master/AXrLottie/build/intermediates/cmake/release/obj/armeabi-v7a/librlottie.so 
  : && /Users/henry/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi16 --gcc-toolchain=/Users/henry/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/henry/Library/Android/sdk/ndk/21.0.6113669/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security  -std=c++14 -Oz -DNDEBUG  -Wl,--exclude-libs,libgcc_real.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,librlottie.so -o /Users/henry/Downloads/AXrLottie-master/AXrLottie/build/intermediates/cmake/release/obj/armeabi-v7a/librlottie.so CMakeFiles/rlottie.dir/src/vector/freetype/v_ft_math.cpp.o CMakeFiles/rlottie.dir/src/vector/freetype/v_ft_raster.cpp.o CMakeFiles/rlottie.dir/src/vector/freetype/v_ft_stroker.cpp.o CMakeFiles/rlottie.dir/src/vector/vrect.cpp.o CMakeFiles/rlottie.dir/src/vector/vdasher.cpp.o CMakeFiles/rlottie.dir/src/vector/vbrush.cpp.o CMakeFiles/rlottie.dir/src/vector/vbitmap.cpp.o CMakeFiles/rlottie.dir/src/vector/vpainter.cpp.o CMakeFiles/rlottie.dir/src/vector/vdrawhelper_common.cpp.o CMakeFiles/rlottie.dir/src/vector/vdrawhelper.cpp.o CMakeFiles/rlottie.dir/src/vector/vdrawhelper_sse2.cpp.o CMakeFiles/rlottie.dir/src/vector/vdrawhelper_neon.cpp.o CMakeFiles/rlottie.dir/src/vector/vrle.cpp.o CMakeFiles/rlottie.dir/src/vector/vpath.cpp.o CMakeFiles/rlottie.dir/src/vector/vpathmesure.cpp.o CMakeFiles/rlottie.dir/src/vector/vmatrix.cpp.o CMakeFiles/rlottie.dir/src/vector/velapsedtimer.cpp.o CMakeFiles/rlottie.dir/src/vector/vdebug.cpp.o CMakeFiles/rlottie.dir/src/vector/vinterpolator.cpp.o CMakeFiles/rlottie.dir/src/vector/vbezier.cpp.o CMakeFiles/rlottie.dir/src/vector/vraster.cpp.o CMakeFiles/rlottie.dir/src/vector/vdrawable.cpp.o CMakeFiles/rlottie.dir/src/vector/vimageloader.cpp.o CMakeFiles/rlottie.dir/src/vector/varenaalloc.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottieitem.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottieitem_capi.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottieloader.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottiemodel.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottieproxymodel.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottieparser.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottieanimation.cpp.o CMakeFiles/rlottie.dir/src/lottie/lottiekeypath.cpp.o  -Wl,--version-script=/Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/rlottie.expmap -ldl -Wl,--no-undefined -latomic -lm && :
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/src/vector/vdrawhelper_neon.cpp:17: error: undefined reference to 'pixman_composite_src_n_8888_asm_neon'
  /Users/henry/Downloads/AXrLottie-master/AXrLottie/src/main/cpp/src/vector/vdrawhelper_neon.cpp:26: error: undefined reference to 'pixman_composite_over_n_8888_asm_neon'
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

could not load needed library 'librlottie.so' for 'libjlottie.so' (load_library[1095]: Library 'librlottie.so' not found)

I got this error when I debugged the app on LG Optimus L9:
java.lang.ExceptionInInitializerError at com.hyapp.a18chat.bl.App.onCreate(App.java:26) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1002) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4252) at android.app.ActivityThread.access$1300(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4849) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1893]: 141 could not load needed library 'librlottie.so' for 'libjlottie.so' (load_library[1095]: Library 'librlottie.so' not found) at java.lang.Runtime.loadLibrary(Runtime.java:370) at java.lang.System.loadLibrary(System.java:538) at com.aghajari.rlottie.AXrLottie.<clinit>(AXrLottie.java:48) at com.hyapp.a18chat.bl.App.onCreate(App.java:26)  at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1002)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4252)  at android.app.ActivityThread.access$1300(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:137)  at android.app.ActivityThread.main(ActivityThread.java:4849)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)  at dalvik.system.NativeStart.main(Native Method) 

This error occurred in this line of code:
AXrLottie.init(this);

Getkeepsafe: Could not find libjlottie.so

Hi!

I faced with an error at some users, stack trace be like:

java.lang.RuntimeException: Unable to create application my.package.MainApplication: com.getkeepsafe.relinker.c: Could not find 'libjlottie.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].

at com.aghajari.rlottie.AXrLottie.init(AXrLottie.java:70)
at my.package.MainApplication.onCreate(MainApplication.kt:45)

As far as i understand getkeepsafe didn't find libjlottie.so lib

We publish the app at google play with app bundle, i have checked aab archive and found that libjlottie.so is persist in arch (arm64-v8a, armeabi-v7a, armeabi - respectively)

We use:
axrLottie - 1.4.0
gradle - 8.1

Random crashes in com.aghajari.rlottie.DispatchQueuePool

    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
        at com.aghajari.rlottie.DispatchQueuePool$2$1.run(DispatchQueuePool.java:102)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7660)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

using with Glide

I believe number of AXrLottieDrawable shown on screen highly affects the probability of the crash

LeakedClosableViolation

I got this error on AXrLottie 1.1.0 but I have not found a fix for this error in any release after 1.1.0.

D/StrictMode: StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.

        at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1924)

        at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:303)

        at java.io.FileOutputStream.finalize(FileOutputStream.java:492)

        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)

        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)

        at java.lang.Daemons$Daemon.run(Daemons.java:139)

        at java.lang.Thread.run(Thread.java:923)

     Caused by: java.lang.Throwable: Explicit termination method 'close' not called

        at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:259)

        at dalvik.system.CloseGuard.open(CloseGuard.java:230)

        at java.io.FileOutputStream.<init>(FileOutputStream.java:253)

        at java.io.FileOutputStream.<init>(FileOutputStream.java:186)

        at com.aghajari.rlottie.extension.GZipFileExtension.toFile(GZipFileExtension.java:58)

        at com.aghajari.rlottie.extension.GZipFileExtension.toFile(GZipFileExtension.java:78)

        at com.aghajari.rlottie.extension.AXrFileExtension.toFile(AXrFileExtension.java:54)

        at com.aghajari.rlottie.decoder.AXrFileReader.read(AXrFileReader.java:107)

        at com.aghajari.rlottie.decoder.AXrFileReader.fromAssets(AXrFileReader.java:83)

        at com.aghajari.rlottie.AXrLottieDrawable.fromAssets(AXrLottieDrawable.java:1272)

        at com.aghajari.rlottie.AXrLottieDrawable.fromAssets(AXrLottieDrawable.java:1268)

        at com.aghajari.rlottie.AXrLottie$Loader.createFromAssets(AXrLottie.java:245)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.