Lotti

DonManfred

Expert
Licensed User
Longtime User
This is a wrap for this Github project.

Example1.gif




Lottie
<link>...|https://www.b4x.com</link>
Author: DonManfred
Version: 3.4
  • LottieAnimationView
    • Functions:
      • addAnimatorListener (listener As Animator.AnimatorListener)
      • addAnimatorUpdateListener (updateListener As ValueAnimator.AnimatorUpdateListener)
      • addLottieOnCompositionLoadedListener (lottieOnCompositionLoadedListener As com.airbnb.lottie.LottieOnCompositionLoadedListener) As Boolean
      • BringToFront
      • buildDrawingCache (autoScale As Boolean)
        If rendering via software, Android will fail to generate a bitmap if the view is too large. Rather than displaying
        nothing, fallback on hardware acceleration which may incur a performance hit.
      • cancelAnimation
      • CreateAnimatorListener As AnimatorListener
      • CreateAnimatorUpdateListener As AnimatorUpdateListener
      • CreateLottieListener As com.airbnb.lottie.LottieListener
      • CreateLottieOnCompositionLoadedListener As com.airbnb.lottie.LottieOnCompositionLoadedListener
      • DesignerCreateView (base As Panel, lw As Label, props As Map)
      • disableExtraScaleModeInFitXY
        Disable the extraScale mode in {@link #draw(Canvas)} function when scaleType is FitXY. It doesn't affect the rendering with other scaleTypes.
        <p>When there are 2 animation layout side by side, the default extra scale mode might leave 1 pixel not drawn between 2 animation, and
        disabling the extraScale mode can fix this problem</p>
        <b>Attention:</b> Disable the extra scale mode can downgrade the performance and may lead to larger memory footprint. Please only disable this
        mode when using animation with a reasonable dimension (smaller than screen size).
      • hasMasks As Boolean
        Returns whether or not any layers in this composition has masks.
      • hasMatte As Boolean
        Returns whether or not any layers in this composition has a matte layer.
      • Initialize (EventName As String)
      • Invalidate
      • Invalidate2 (arg0 As android.graphics.Rect)
      • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • invalidateDrawable (dr As Drawable)
      • IsInitialized As Boolean
      • loop (loop As Boolean)
      • pauseAnimation
      • playAnimation
        Plays the animation from the beginning. If speed is < 0, it will start at the end
        and play towards the beginning
      • removeAllAnimatorListeners
      • removeAllLottieOnCompositionLoadedListener
      • removeAllUpdateListeners
      • removeAnimatorListener (listener As Animator.AnimatorListener)
      • removeLottieOnCompositionLoadedListener (lottieOnCompositionLoadedListener As com.airbnb.lottie.LottieOnCompositionLoadedListener) As Boolean
      • removeUpdateListener (updateListener As ValueAnimator.AnimatorUpdateListener)
      • RemoveView
      • RequestFocus As Boolean
      • resumeAnimation
        Continues playing the animation from its current position. If speed < 0, it will play backwards
        from the current position.
      • reverseAnimationSpeed
        Reverses the current animation speed. This does NOT play the animation.
      • SendToBack
      • setAnimation2 (Type As String, Name As String)
        Sets the animation from a file in the raw directory.
        This will load and deserialize the file asynchronously.
        Type:
        Name:
      • setAnimation3 (stream As java.io.InputStream, cacheKey As String)
        Sets the animation from an arbitrary InputStream.
        This will load and deserialize the file asynchronously.
        <p>
        This is particularly useful for animations loaded from the network. You can fetch the
        bodymovin json from the network and pass it directly here.
      • setAnimationFromJson (jsonString As String, cacheKey As String)
        Sets the animation from json string. This is the ideal API to use when loading an animation
        over the network because you can use the raw response body here and a conversion to a
        JSONObject never has to be done.
      • setAnimationFromUrl2 (url As String, cacheKey As String)
        Load a lottie animation from a url. The url can be a json file or a zip file. Use a zip file if you have images. Simply zip them together and lottie
        will unzip and link the images automatically.
        Under the hood, Lottie uses Java HttpURLConnection because it doesn't require any transitive networking dependencies. It will download the file
        to the application cache under a temporary name. If the file successfully parses to a composition, it will rename the temporary file to one that
        can be accessed immediately for subsequent requests. If the file does not parse to a composition, the temporary file will be deleted.
      • SetBackgroundImage (arg0 As android.graphics.Bitmap) As BitmapDrawable
      • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
      • setImageResource (Type As String, Name As String)
      • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
      • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
      • setMinAndMaxFrame2 (startMarkerName As String, endMarkerName As String, playEndMarkerStartFrame As Boolean)
        Sets the minimum and maximum frame to the start marker start and the maximum frame to the end marker start.
        playEndMarkerStartFrame determines whether or not to play the frame that the end marker is on. If the end marker
        represents the end of the section that you want, it should be true. If the marker represents the beginning of the
        next section, it should be false.
      • setMinAndMaxFrame3 (minFrame As Int, maxFrame As Int)
      • setMinAndMaxProgress (minProgress As Float, maxProgress As Float)
      • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
      • updateBitmap (id As String, bitmap As Object) As Bitmap
        Allows you to modify or clear a bitmap that was loaded for an image either automatically
        through {@link #setImageAssetsFolder(String)} or with an {@link ImageAssetDelegate}.
        Return type: @return:the previous Bitmap or null.
    • Properties:
      • Animating As Boolean [read only]
      • Animation As String [write only]
      • AnimationFromUrl As String [write only]
        Load a lottie animation from a url. The url can be a json file or a zip file. Use a zip file if you have images. Simply zip them together and lottie
        will unzip and link the images automatically.
        Under the hood, Lottie uses Java HttpURLConnection because it doesn't require any transitive networking dependencies. It will download the file
        to the application cache under a temporary name. If the file successfully parses to a composition, it will rename the temporary file to one that
        can be accessed immediately for subsequent requests. If the file does not parse to a composition, the temporary file will be deleted.
      • ApplyingOpacityToLayersEnabled As Boolean [write only]
        Sets whether to apply opacity to the each layer instead of shape.
        <p>
        Opacity is normally applied directly to a shape. In cases where translucent shapes overlap, applying opacity to a layer will be more accurate
        at the expense of performance.
        <p>
        The default value is false.
        <p>
        Note: This process is very expensive. The performance impact will be reduced when hardware acceleration is enabled.
      • Background As android.graphics.drawable.Drawable
      • CacheComposition As Boolean [write only]
        If set to true, all future compositions that are set will be cached so that they don't need to be parsed
        next time they are loaded. This won't apply to compositions that have already been loaded.
        Defaults to true.
        {@link R.attr#lottie_cacheComposition}
      • Color As Int [write only]
      • Composition As com.airbnb.lottie.LottieComposition
        Sets a composition.
        You can set a default cache strategy if this view was inflated with xml by
        using {@link R.attr#lottie_cacheStrategy}.
      • Duration As Long [read only]
      • Enabled As Boolean
      • FailureListener As com.airbnb.lottie.LottieListener [write only]
        Set a default failure listener that will be called if any of the setAnimation APIs fail for any reason.
        This can be used to replace the default behavior.
        The default behavior will log any network errors and rethrow all other exceptions.
        If you are loading an animation from the network, errors may occur if your user has no internet.
        You can use this listener to retry the download or you can have it default to an error drawable
        with {@link #setFallbackResource(int)}.
        Unless you are using {@link #setAnimationFromUrl(String)}, errors are unexpected.
        Set the listener to null to revert to the default behavior.
      • FallbackResource As Int [write only]
        Set a drawable that will be rendered if the LottieComposition fails to load for any reason.
        Unless you are using {@link #setAnimationFromUrl(String)}, this is an unexpected error and
        you should handle it with {@link #setFailureListener(LottieListener)}.
        If this is a network animation, you may use this to show an error to the user or
        you can use a failure listener to retry the download.
      • Frame As Int
        Get the currently rendered frame.
      • Height As Int
      • ImageAssetsFolder As String
        If you use image assets, you must explicitly specify the folder in assets/ in which they are
        located because bodymovin uses the name filenames across all compositions (img_#).
        Do NOT rename the images themselves.
        If your images are located in src/main/assets/airbnb_loader/ then call
        `setImageAssetsFolder("airbnb_loader/");`.
        Be wary if you are using many images, however. Lottie is designed to work with vector shapes
        from After Effects. If your images look like they could be represented with vector shapes,
        see if it is possible to convert them to shape layers and re-export your animation. Check
        the documentation at http://airbnb.io/lottie for more information about importing shapes from
        Sketch or Illustrator to avoid this.
      • ImageBitmap As Object [write only]
      • ImageDrawable As Drawable [write only]
      • Left As Int
      • MaxFrame As Float
        Returns the maximum frame set by {@link #setMaxFrame(int)} or {@link #setMaxProgress(float)}
      • MaxFrame2 As String [write only]
        Sets the maximum frame to the start time + duration of the specified marker.
      • MaxProgress As Float [write only]
        Sets the maximum progress that the animation will end at when playing or looping.
      • MergePathsEnabledForKitKatAndAbove As Boolean [read only]
        Returns whether merge paths are enabled for KitKat and above.
      • MergePathsForKitKatAndAbove As Boolean [write only]
        Enable this to get merge path support for devices running KitKat (19) and above.
        Merge paths currently don't work if the the operand shape is entirely contained within the
        first shape. If you need to cut out one shape from another shape, use an even-odd fill type
        instead of using merge paths.
      • MinAndMaxFrame As String [write only]
        Sets the minimum and maximum frame to the start time and start time + duration
        of the specified marker.
      • MinFrame As Float
        Returns the minimum frame set by {@link #setMinFrame(int)} or {@link #setMinProgress(float)}
      • MinFrame2 As String [write only]
        Sets the minimum frame to the start time of the specified marker.
      • MinProgress As Float [write only]
        Sets the minimum progress that the animation will start from when playing or looping.
      • Padding As Int()
      • Parent As Object [read only]
      • PerformanceTracker As com.airbnb.lottie.PerformanceTracker [read only]
      • PerformanceTrackingEnabled As Boolean [write only]
      • Progress As Float
      • RenderMode As com.airbnb.lottie.RenderMode [write only]
        Call this to set whether or not to render with hardware or software acceleration.
        Lottie defaults to Automatic which will use hardware acceleration unless:
        1) There are dash paths and the device is pre-Pie.
        2) There are more than 4 masks and mattes and the device is pre-Pie.
        Hardware acceleration is generally faster for those devices unless
        there are many large mattes and masks in which case there is a ton
        of GPU uploadTexture thrashing which makes it much slower.
        In most cases, hardware rendering will be faster, even if you have mattes and masks.
        However, if you have multiple mattes and masks (especially large ones) then you
        should test both render modes. You should also test on pre-Pie and Pie+ devices
        because the underlying rendering enginge changed significantly.
      • RepeatCount As Int
        Defines how many times the animation should repeat. The default value
        is 0.
      • RepeatMode As Int
        Defines what this animation should do when it reaches the end.
      • SafeMode As Boolean [write only]
        If you are experiencing a device specific crash that happens during drawing, you can set this to true
        for those devices. If set to true, draw will be wrapped with a try/catch which will cause Lottie to
        render an empty frame rather than crash your app.
        Ideally, you will never need this and the vast majority of apps and animations won't. However, you may use
        this for very specific cases if absolutely necessary.
        There is no XML attr for this because it should be set programmatically and only for specific devices that
        are known to be problematic.
      • Scale As Float
        Set the scale on the current composition. The only cost of this function is re-rendering the
        current frame so you may call it frequent to scale something up or down.
        The smaller the animation is, the better the performance will be. You may find that scaling an
        animation down then rendering it in a larger ImageView and letting ImageView scale it back up
        with a scaleType such as centerInside will yield better performance with little perceivable
        quality loss.
        You can also use a fixed view width/height in conjunction with the normal ImageView
        scaleTypes centerCrop and centerInside.
      • ScaleType As String [write only]
      • Speed As Float
        Returns the current playback speed. This will be < 0 if the animation is playing backwards.
      • Tag As Object
      • Top As Int
      • Visible As Boolean
      • Width As Int
  • LottieCompositionFactory
    • Events:
      • onResult (success As Boolean, result As Object)
    • Functions:
      • clearCache
      • fromAsset (fileName As String)
        Parse an animation from src/main/assets. It is recommended to use {@link #fromRawRes(Context, int)} instead.
        The asset file name will be used as a cache key so future usages won't have to parse the json again.
        However, if your animation has images, you may package the json and images as a single flattened zip file in assets.
        To skip the cache, add null as a third parameter.
      • fromAsset2 (fileName As String, cacheKey As String)
        Parse an animation from src/main/assets. It is recommended to use {@link #fromRawRes(Context, int)} instead.
        The asset file name will be used as a cache key so future usages won't have to parse the json again.
        However, if your animation has images, you may package the json and images as a single flattened zip file in assets.
        Pass null as the cache key to skip the cache.
      • fromAssetSync (fileName As String) As com.airbnb.lottie.LottieResult
        Parse an animation from src/main/assets. It is recommended to use {@link #fromRawRes(Context, int)} instead.
        The asset file name will be used as a cache key so future usages won't have to parse the json again.
        However, if your animation has images, you may package the json and images as a single flattened zip file in assets.
        To skip the cache, add null as a third parameter.
      • fromAssetSync2 (context As Context, fileName As String, cacheKey As String) As com.airbnb.lottie.LottieResult
        Parse an animation from src/main/assets. It is recommended to use {@link #fromRawRes(Context, int)} instead.
        The asset file name will be used as a cache key so future usages won't have to parse the json again.
        However, if your animation has images, you may package the json and images as a single flattened zip file in assets.
        Pass null as the cache key to skip the cache.
      • fromJson (json As JSONObject, cacheKey As String)
      • fromJsonInputStream (stream As java.io.InputStream, cacheKey As String)
        Auto-closes the stream.
      • fromJsonInputStreamSync (stream As java.io.InputStream, cacheKey As String) As com.airbnb.lottie.LottieResult
        Return a LottieComposition for the given InputStream to json.
      • fromJsonReader (reader As com.airbnb.lottie.parser.moshi.JsonReader, cacheKey As String)
      • fromJsonReaderSync (reader As com.airbnb.lottie.parser.moshi.JsonReader, cacheKey As String) As com.airbnb.lottie.LottieResult
      • fromJsonString (json As String, cacheKey As String)
      • fromJsonStringSync (json As String, cacheKey As String) As com.airbnb.lottie.LottieResult
        Return a LottieComposition for the specified raw json string.
        If loading from a file, it is preferable to use the InputStream or rawRes version.
      • fromJsonSync (json As JSONObject, cacheKey As String) As com.airbnb.lottie.LottieResult
        Prefer passing in the json string directly. This method just calls `toString()` on your JSONObject.
        If you are loading this animation from the network, just use the response body string instead of
        parsing it first for improved performance.
      • fromUrl (url As String)
        Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
        future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
        might need an animation in the future.
        To skip the cache, add null as a third parameter.
      • fromUrl2 (url As String, cacheKey As String)
        Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
        future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
        might need an animation in the future.
      • fromUrlSync (context As Context, url As String) As com.airbnb.lottie.LottieResult
        Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
        future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
        might need an animation in the future.
      • fromUrlSync2 (context As Context, url As String, cacheKey As String) As com.airbnb.lottie.LottieResult
        Fetch an animation from an http url. Once it is downloaded once, Lottie will cache the file to disk for
        future use. Because of this, you may call `fromUrl` ahead of time to warm the cache if you think you
        might need an animation in the future.
      • fromZipStream (inputStream As java.util.zip.ZipInputStream, cacheKey As String)
      • fromZipStreamSync (inputStream As java.util.zip.ZipInputStream, cacheKey As String) As com.airbnb.lottie.LottieResult
        Parses a zip input stream into a Lottie composition.
        Your zip file should just be a folder with your json file and images zipped together.
        It will automatically store and configure any images inside the animation if they exist.
      • Initialize (EventName As String)
      • IsInitialized As Boolean
    • Properties:
      • MaxCacheSize As Int [write only]
        Set the maximum number of compositions to keep cached in memory.
        This must be > 0.


Download the additional aar containing the Lottie json files here:
 

Attachments

  • LottieV1.0.zip
    129.6 KB · Views: 772
  • LottieEx.zip
    8.6 KB · Views: 715
  • LottieV3.4.zip
    370.7 KB · Views: 850
Last edited:

monic

Active Member
Licensed User
Longtime User
Hi, When I try and compile any of the two examples it complains about the customviews I'm i missing somethings

v6.50 / API 25 on a Android 5.0

B4X:
LogCat connected to: 9411b0a1
--------- beginning of main
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 340)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at lottie.a.main._activity_create(main.java:340)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at lottie.a.main.afterFirstLayout(main.java:102)
    at lottie.a.main.access$000(main.java:17)
    at lottie.a.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5938)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: com.airbnb.lottie.LottieAnimationView
    at de.donmanfred.LottieAnimationViewWrapper._initialize(LottieAnimationViewWrapper.java:74)
    ... 20 more
--------- beginning of system
** Service (pushservice) Start **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 341)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at lottie.a.main._activity_create(main.java:341)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at lottie.a.main.afterFirstLayout(main.java:102)
    at lottie.a.main.access$000(main.java:17)
    at lottie.a.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5938)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: com.airbnb.lottie.LottieAnimationView
    at de.donmanfred.LottieAnimationViewWrapper._initialize(LottieAnimationViewWrapper.java:74)
    ... 20 more
** Service (pushservice) Start **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 341)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at lottie.a.main._activity_create(main.java:341)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at lottie.a.main.afterFirstLayout(main.java:102)
    at lottie.a.main.access$000(main.java:17)
    at lottie.a.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5938)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: com.airbnb.lottie.LottieAnimationView
    at de.donmanfred.LottieAnimationViewWrapper._initialize(LottieAnimationViewWrapper.java:74)
    ... 20 more
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 341)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at pp.am.ok.main._activity_create(main.java:341)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at pp.am.ok.main.afterFirstLayout(main.java:102)
    at pp.am.ok.main.access$000(main.java:17)
    at pp.am.ok.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5938)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: com.airbnb.lottie.LottieAnimationView
    at de.donmanfred.LottieAnimationViewWrapper._initialize(LottieAnimationViewWrapper.java:74)
    ... 20 more
** Service (pushservice) Start **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 341)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.example.lottery.main._activity_create(main.java:341)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at b4a.example.lottery.main.afterFirstLayout(main.java:102)
    at b4a.example.lottery.main.access$000(main.java:17)
    at b4a.example.lottery.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5938)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 16 more
Caused by: java.lang.NoClassDefFoundError: com.airbnb.lottie.LottieAnimationView
    at de.donmanfred.LottieAnimationViewWrapper._initialize(LottieAnimationViewWrapper.java:74)
    ... 20 more
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
with the new .jar file comes this error:

B4X:
B4A version: 7.00 BETA #3
Parsing code.    (0.00s)
Compiling code.    (0.14s)
Compiling layouts code.    (0.03s)
Organizing libraries.    (2.75s)
Generating R file.    Error
invalid resource directory name: C:\Users\Ich\Desktop\Lottie\Objects\bin\extra\res2\res/values-b+sr+Latn
 

fredo

Well-Known Member
Licensed User
Longtime User
Try the attached jar file
Same error as in #6.

New error at runtime:
B4X:
LogCat connected
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 339)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.example.lotti.main._activity_create(main.java:339)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at b4a.example.lotti.main.afterFirstLayout(main.java:102)
    at b4a.example.lotti.main.access$000(main.java:17)
    at b4a.example.lotti.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6121)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 14 more
Caused by: java.lang.IllegalStateException: Unable to find file Mobilo/BlinkingCursor.json
    at com.airbnb.lottie.model.LottieComposition.fromAssetFileName(LottieComposition.java:51)
    at com.airbnb.lottie.LottieFontViewGroup.init(LottieFontViewGroup.java:49)
    at com.airbnb.lottie.LottieFontViewGroup.<init>(LottieFontViewGroup.java:34)
    at de.donmanfred.LottieFontViewGroupWrapper._initialize(LottieFontViewGroupWrapper.java:75)
    ... 17 more
Caused by: java.io.FileNotFoundException: Mobilo/BlinkingCursor.json
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:347)
    at android.content.res.AssetManager.open(AssetManager.java:321)
    at com.airbnb.lottie.model.LottieComposition.fromAssetFileName(LottieComposition.java:49)
    ... 20 more
** Activity (actprocesscards) Resume **
 
Last edited:

fredo

Well-Known Member
Licensed User
Longtime User
Example from post #2

After opening project:
31-05-_2017_11-47-05.png

Without further actions compiled and installed.

Then:
B4X:
LogCat connected
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 339)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.example.lotti.main._activity_create(main.java:339)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at b4a.example.lotti.main.afterFirstLayout(main.java:102)
    at b4a.example.lotti.main.access$000(main.java:17)
    at b4a.example.lotti.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6121)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 14 more
Caused by: java.lang.IllegalStateException: Unable to find file Mobilo/BlinkingCursor.json
    at com.airbnb.lottie.model.LottieComposition.fromAssetFileName(LottieComposition.java:51)
    at com.airbnb.lottie.LottieFontViewGroup.init(LottieFontViewGroup.java:49)
    at com.airbnb.lottie.LottieFontViewGroup.<init>(LottieFontViewGroup.java:34)
    at de.donmanfred.LottieFontViewGroupWrapper._initialize(LottieFontViewGroupWrapper.java:75)
    ... 17 more
Caused by: java.io.FileNotFoundException: Mobilo/BlinkingCursor.json
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:347)
    at android.content.res.AssetManager.open(AssetManager.java:321)
    at com.airbnb.lottie.model.LottieComposition.fromAssetFileName(LottieComposition.java:49)
    ... 20 more
 

Alexander Stolte

Expert
Licensed User
Longtime User
wich librarys is needed? IME and Lotty with the new .jar file? or i need a another library?

i had try the second example from Marco, but it comes this Error:

B4X:
Logger connected to:  samsung SM-G935F
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 38 (Main)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6692)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 17 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/airbnb/lottie/LottieAnimationView;
    at de.donmanfred.LottieAnimationViewWrapper._initialize(LottieAnimationViewWrapper.java:74)
    ... 20 more
Caused by: java.lang.ClassNotFoundException: com.airbnb.lottie.LottieAnimationView
    at java.lang.VMClassLoader.findLoadedClass(Native Method)
    at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 21 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/AppCompatImageView;
    ... 21 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.AppCompatImageView" on path: DexPathList[[zip file "/data/app/b4a.example-1/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-1/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    ... 21 more
 

SMOOTSARA

Active Member
Licensed User
Longtime User
Hi DonManfred :)

Is this library another prerequisite?
for example (app compat)

In android v 7.1.1 without this library will not run :(

B4X:
B4A Version: 8.30 BETA #1
Parsing code.    (0.00s)
Compiling code.    (0.03s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (1.02s)
Generating R file.    (0.23s)
Compiling generated Java code.    Error
B4A line: 44
Activity.AddView(lottie,10%y,10%x,80%x,50%y)
src\b4a\example\main.java:346: error: cannot access AppCompatImageView
mostCurrent._activity.AddView((android.view.View)(mostCurrent._lottie.getObject()),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (10),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (10),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (80),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (50),mostCurrent.activityBA));
                              ^
  class file for android.support.v7.widget.AppCompatImageView not found



my cod


B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

#AdditionalRes: ..\res.Lottie
#DebuggerForceStandardAssets: true
 #BridgeLogger: True
 
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    Private lottie As LottieAnimationView
    Private comp As LottieComposition
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
   
'    Activity.LoadLayout("Layout1")
    'lottie.SetAnimation2("slide_in_right",lottie.CacheStrategyStrong)
   
   
    lottie.Initialize("lottie")
    Activity.AddView(lottie,10%y,10%x,80%x,50%y)
    lottie.autoloop(True)
    Dim json As String
    'json = File.ReadString(File.DirAssets, "trimpathsfull.json")
    json = File.ReadString(File.DirAssets, "loopplayonce.json")

    comp.InitializefromJson("Lottie",json)
End Sub

Sub Activity_Resume

End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Lottie_onAnimationUpdate(animator As Object)
    'Log($"Lottie_onAnimationUpdate"$)
End Sub
Sub Lottie_onCompositionLoaded(composition As Object)
    Log($"Lottie_onCompositionLoaded"$)
    lottie.Composition = composition
    lottie.playAnimation
   
End Sub


Is it possible to publish a new version of this functional library without dependency?
Thank you
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
for example (app compat)
AppCompat is needed
Is it possible to publish a new version of this functional library without dependency?
No.
1. The Requirements are in the Lib itself (Github project). I cannot change it
2. I do not have the Source of this Library anymore due to my HDD Crash last year. I cannot change anything again..
3. DO NOT change Fontsize and/or Color. It just makes your post more difficult to read!
 
Top