Explore all Animation open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Animation

animate.css

v4.1.1

manim

ManimGL 1.6.1

anime

v3.2.1

lottie-android

5.0.3

react-spring

v9.4.5-beta.1

Popular Libraries in Animation

animate.css

by animate-css doticoncssdoticon

star image 74293 doticonNOASSERTION

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.

LeetCodeAnimation

by MisterBooo doticonjavadoticon

star image 66783 doticon

Demonstrate all the questions on LeetCode in the form of animation.(用动画的形式呈现解LeetCode题目的思路)

manim

by 3b1b doticonpythondoticon

star image 43754 doticonMIT

Animation engine for explanatory math videos

anime

by juliangarnier doticonjavascriptdoticon

star image 40224 doticonMIT

JavaScript animation engine

lottie-android

by airbnb doticonjavadoticon

star image 32616 doticonApache-2.0

Render After Effects animations natively on Android and iOS, Web, and React Native

react-spring

by pmndrs doticontypescriptdoticon

star image 22856 doticonMIT

✌️ A spring physics based React animation library

lottie-ios

by airbnb doticonswiftdoticon

star image 22558 doticonApache-2.0

An iOS library to natively render After Effects vector animations

Hero

by HeroTransitions doticonswiftdoticon

star image 20722 doticonMIT

Elegant transition library for iOS & tvOS

react-motion

by chenglou doticonjavascriptdoticon

star image 20656 doticonMIT

A spring that solves your animation problems.

Trending New libraries in Animation

manim

by ManimCommunity doticonpythondoticon

star image 9720 doticonMIT

A community-maintained Python framework for creating mathematical animations.

pose-animator

by yemount doticonjavascriptdoticon

star image 8018 doticonApache-2.0

rough-notation

by rough-stuff doticontypescriptdoticon

star image 5517 doticonMIT

Create and animate hand-drawn annotations on a web page

html-css

by gustavoguanabara doticonhtmldoticon

star image 4011 doticonMIT

Curso de HTML5 e CSS3

boring-avatars

by boringdesigners doticonjavascriptdoticon

star image 3457 doticonMIT

Boring avatars is a tiny JavaScript React library that generates custom, SVG-based avatars from any username and color palette.

ani-cli

by pystardust doticonshelldoticon

star image 3401 doticonGPL-3.0

A cli tool to browse and play anime

svg-path-editor

by Yqnn doticontypescriptdoticon

star image 2496 doticonApache-2.0

Online editor to create and manipulate SVG paths

moti

by nandorojo doticontypescriptdoticon

star image 2322 doticon

🐼 The React Native (+ Web) animation library, powered by Reanimated 2.

AnimeXStream

by mukul500 doticonkotlindoticon

star image 1869 doticonMIT

An Android app to watch anime on your phone without ads.

Top Authors in Animation

1

codrops

103 Libraries

star icon28528

2

mattdesl

27 Libraries

star icon3226

3

londonappbrewery

25 Libraries

star icon59

4

CodyHouse

23 Libraries

star icon1500

5

alikinvv

19 Libraries

star icon445

6

hughsk

18 Libraries

star icon233

7

mrmrs

17 Libraries

star icon163

8

substack

17 Libraries

star icon403

9

svgdotjs

17 Libraries

star icon10211

10

tutsplus

15 Libraries

star icon100

1

103 Libraries

star icon28528

2

27 Libraries

star icon3226

3

25 Libraries

star icon59

4

23 Libraries

star icon1500

5

19 Libraries

star icon445

6

18 Libraries

star icon233

7

17 Libraries

star icon163

8

17 Libraries

star icon403

9

17 Libraries

star icon10211

10

15 Libraries

star icon100

Trending Kits in Animation

We can create any animation with suitable libraries or combinations of libraries in Python that are well-known for their functionalities and functionalities. For developers looking for options with less complex code with maximum customization options, users can customize their plots and designs depending on their preferences.   


Choosing a suitable library plays a key role in any machine learning or data science project, and we should do it properly to avoid other related issues which may arise. Some libraries offer an interactive plot to attract playing with the graph and visualize it uniquely. It will allow you to edit videos, create animations, and create a map or geological animations where we can analyze the geological data.  


Here is the list of handpicked 18 best Python Animation Libraries in 2023 which will help you with your animation requirements: 

manim - 3b1b: 

  • Is a Python library for creating mathematical animations and educational videos that Grant Sanderson develops.  
  • Is an open source library that allows users to create high-quality animations which visualize mathematical concepts like animations of graphs, functions, fractals, and more.   
  • Uses Python code for creating animations which we can export to animated GIFs or video files.  

PythonRobotics: 

  • Is a Python library for implementing different robotics simulations, visualizations, and algorithms. 
  • Offers various resources and tools for robotics developers, like algorithms for path planning, localization, motion control, mapping, and many more.   
  • Includes simulation environments like 2D and 3D simulators, that will allow developers to test their algorithms in virtual environments before deploying them on real robots.   

matplotlib: 

  • Is a comprehensive library for creating animated, interactive visualizations and static in Python. 
  • Produces publication-quality figures in different interactive environments and hardcopy formats across platforms. 
  • Can be used in Python Scripts, web application servers, various graphical user interface toolkits, and Python/IPython shells.  

manim - ManimCommunity:  

  • Is an animation engine for explanatory math videos used for programmatically creating precise animations. 
  • Includes various tools for creating animations like support for vector graphics, 3D objects, and complex mathematical equations. 
  • Also includes features for creating animations with custom fonts, styles, and colors.  

plotly.py: 

  • Is a Python library used to create interactive data visualizations, built on the plotly JavaScript library that allows developers to create various interactive plots.   
  • Is designed to be easy to use and includes different resources and tools for creating high-quality visualizations. 
  • Includes support for complex data structures like pandas DataFrames and offers various customization options for fonts, styles, and colors.  

seaborn: 

  • Is a Python data visualization library based on Matplotlib, offering a high-level interface to create attractive and informative statistical graphics.  
  • Offers various plotting functions for visualizing various data types like continuous data, data distribution, and categorial data.  
  • Its the ability to create visually appealing plots with minimal effort and supports the customization of plot elements like axes, titles, legends, and labels. 

moviepy: 

  • Is a Python library for video editing, concatenations, cutting, video composting, title insertions, creation of custom effects, and video processing. 
  • Has the ability to add audio to video clips easily and offers various filters and audio effects like changing pitch and speed, adding sound effects, and adjusting volume.  
  • Includes support for creating animations like moving text, images, and shapes and allows users to export their video clips to different file formats. 

termtosvg: 

  • Is a Python library that allows users to record terminal sessions and save them as SVG animations.  
  • Produces clean-looking and lightweight still frames embeddable on the project page or animations.  
  • Includes support for recording multiple terminal sessions, allowing users to control the size and speed of the resulting animation.   

altair: 

  • Is a declarative statistical visualization library that can help you spend more time understanding your data and its meaning. 
  • Offers a simple syntax for creating different visualizations, like line charts, histograms, scatterplots, and bar charts. 
  • Its declarative syntax lets user's express visualizations as a series of high-level mappings between visual and data properties like color, size, and position. 

PathPlanning: 

  • Is a Python library used for path and motion planning applications designed to be accessible to beginners and experts with a straightforward API. 
  • Offers various algorithms for computing collision-free paths for drones, mobile robots, and manipulators in 2D and 3D environments. 
  • Also offers tools for trajectory generation, motion control, and obstacle avoidance and supports simulation and visualization of robot motion. 

alive-progress: 

  • Is a Python library for displaying spinners and progress bars in command-line applications designed to offer a customizable way of showing progress indicators for long-running processes or tasks. 
  • Supports for pausing and resuming progress indicators, nested spinners, and progress bars.  
  • Designed to be intuitive and simple with various default settings and a straightforward API for customizing the behavior and appearance of spinners and progress bars. 

asciimatics: 

  • Is a package for helping people create full-screen text UIs on any platform and offers a single cross-platform Python class to do all the low-level console functions. 
  • Includes cursor positioning, mouse input, screen scraping, colored/styled text, detecting and handling if the console resizes, and keyboard input like Unicode support. 
  • Is a Python library for creating text-based animations and user interfaces in the terminal. 

pygal: 

  • Is a Python library for creating interactive Scalable Vector Graphics (SVG) graphs and charts. 
  • Offers various tools for generating customizable charts, graphs, and high-quality for use in presentations, reports, and web applications. 
  • Includes built-in support for data/time axis labeling, responsive design, and integration with web frameworks and interactive charts elements.   

GANimation: 

  • Is a Python implementation of the GANimation research project, which offers various tools for generating animations from still images using Generative Adversarial Networks (GANs).  
  • Includes tools for augmenting and preprocessing input data, customizable GAN training parameters and architecture, and support for evaluating and visualizing GAN models.  
  • Offers various tools for fine-tuning GAN models and generating high-quality animations for various applications. 

deep-motion-editing: 

  • Offers advanced and fundamental functions to work with 3D character animations in deep learning with Pytorch. 
  • Is a Python implementation of the research project of the same name, which offers tools for editing the motion of human characters in video sequences using deep learning methods.  
  • Its ability to generate realistic, high-quality animations for various applications offers tools for fine-tuning the deep learning model and editing the generated motions to achieve the desired results. 

geoplotlib: 

  • Is a Python library for creating geographical maps and visualizations and offers an easy-to-use interface for creating maps with different data types, like polygons, heatmaps, lines, and points. 
  • Includes support for different tile providers and map projections, customizable styling options for data layers like size, transparency, and color. 
  • Designed for creating interactive maps and visualizations and is suitable for various applications like data analysis, presentation, and exploration. 

Linux-Fake-Background-Webcam: 

  • Is a Python library that will allow users to replace their webcam background with a custom video or image on Linux systems.  
  • Works by creating a virtual webcam device that can be selected as the input source in video conferencing applications, allowing users to appear as if they are in various environments and locations.   
  • Includes the ability to control the position and size of the custom background video or image and support for replacing the webcam background with a custom video or audio. 

celluloid: 

  • Is a Python library that offers a simple interface for creating visualizations and animations in Matplotlib   
  • Designed to make it easy for users to create animations without having to write to deal with low-level details and complex code.  
  • Includes a simple interface for adding and updating data in the animation, the ability to save the animation as an MP4 or GIF video file, and support for customizing the animation style and appearance. 

React libraries enable developers to craft fluid user interfaces with reusable, ready UI code components. Creating animations is more convenient with the JavaScript virtual DOM programming model of React as compared to the traditional DOM, which helps in boosting performance. Props-based data binding in React libraries enables better flow, efficient debugging and also helps developers reduce some of the boilerplates. Using React libraries gives a coder a cleaner, more responsive approach to animations since the code is easier to reason about. An open platform React animation library supports full-stack programming, making it a holistic solution for web and app-based animations. Presented below is an updated JavaScript library list for React animation packages. lottie-web - Effects animations natively; react-motion - A spring that solves your animation problems; react-native-animatable - Standard set of easy to use animations.

Matplotlib is a Python data visualization toolkit. It will enable users to construct a variety of visualizations. It will enable visualizations like line plots, scatter plots, bar charts, histograms, and others. It is one of the most used libraries for data visualization in the Python environment. It is used in engineering and scientific applications. Large datasets may be handled and visualized because of Matplotlib's seamless integration.


The capability of Matplotlib to produce interactive visuals is one of its core features. Using the Matplotlib widget library, which offers a variety of interactive widgets. Moreover, it offers a significant degree of customization. It will enable users to edit their visualizations' colors, fonts, axes, labels, and other elements. It will let the users can add interaction and communication to their plots.


For making animated visualizations, Matplotlib's FuncAnimation class is a helpful resource. You must first construct a figure and axis object and plot your initial data before you can use FuncAnimation. The data in your plot is then updated by a function you write. This FuncAnimation function calls at predetermined intervals. It updates the data and provides a string of Artist objects that represent the revised plot. You can refresh the information in your plot at predetermined intervals. It will provide the impression of motion or change over time.


Preview of the output obtained when funcAnimation class is used.

Code

The im object in Matplotlib is an instance of the imshow class that is used to display a 2D array as an image. The data shown in the image is updated for each frame of the animation using the set array method of the im object.

We are instructing FuncAnimation to update only the im object on each frame rather than redrawing the full figure by returning im from the animate function. Especially for large and complicated visualisations, this can lead to greater performance and smoother animations.

The FuncAnimation object, which contains all the data required to produce and control the animation, is returned by the create video function's return anim statement.

Follow the steps carefully to get the output easily.

  • Install Visual Studio Code in your computer.
  • Install the required library by using the following commands

pip install matplotlib

pip install numpy


  • If your system is not reflecting the installation, try running the above command by opening windows powershell as administrator.
  • Open the folder in the code editor, copy and paste the above kandi code snippet in the python file.
  • Remove the first line of the code.
  • Run the code using the run command.


I hope you found this useful. I have added the link to dependent libraries, version information in the following sections.


I found this code snippet by searching for "Create animations in Matplotlib using the FuncAnimation class" in kandi. You can try any such use case!

Dependent Libraries

If you do not have numpy and matplotlib that is required to run this code, you can install it by clicking on the above link and copying the pip Install command from the pages in kandi.


You can search for any dependent library on kandi like matplotlib.

Environment tested

  1. This code had been tested using python version 3.8.0
  2. numpy version 1.24.2 has been used.
  3. matplotlib version 3.7.1 has been used.

Support

  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

Here are some famous React Animation Bot Libraries. Some of the use cases of React Animation Libraries include Creating custom page transitions, animating user interface elements, animating data visualisations, Animating complex user interfaces. 


React animation libraries are JavaScript libraries that provide a set of tools to animate components in a React application. These libraries make it easy to animate various components such as buttons, dropdowns, modals, and other user interface elements. They provide powerful APIs that allow developers to create complex animations with minimal code. 


Let us look at the libraries in detail below. 

react-spring 

  • Utilizes physical equations and damping functions to create realistic and natural animations. 
  • Integrates with any other animation library. 
  • Highly optimized for performance, making it a great choice for complex animations. 

react-native-reanimated 

  • Support for both imperative and declarative APIs. 
  • Support for interpolation and value transformations. 
  • Ability to use native platform-specific animations (e.g., spring animations on iOS). 

animated 

  • Provides a comprehensive and flexible API for declarative and imperative animation control. 
  • Only library to offer React Native support. 
  • Allows developers to animate components directly from the React Native bridge.

react-anime 

  • Modular structure allows developers to create custom animations from individual components. 
  • Allows developers to create smooth transitions between different states of their animation. 
  • Offers unique easing functions to create a variety of animation styles. 

react-animation 

  • Supports both CSS and JavaScript animations, making it easy to customize and animate components. 
  • Offers a wide variety of animations such as sliding, fading, and scaling. 
  • Allows developers to chain multiple animations together to create complex sequences. 

moti 

  • Advanced features such as timeline-based animation sequencing. 
  • Supports both native and JavaScript-based animations. 
  • Includes an extensive library of pre-built animations. 

Resonance 

  • Offers a robust set of tools to customize and manage animations. 
  • Designed to be performant, meaning that animations run smoothly on all devices. 
  • Provides an easy way to create complex animations, along with a variety of interpolation methods and easing functions. 

react-animation-comparison 

  • Provides a comprehensive suite of tools and features. 
  • Powerful animation library and an intuitive GUI. 
  • Has a built-in timeline and animation editor. 

renature 

  • Lightweight library that is designed to make animations easy to implement. 
  • It offers a wide range of animation options. 
  • Provides an animation editor that allows users to generate animations quickly and easily. 

Lottie-react 

  • Completely open-source, allowing developers to customize and extend the library as they see fit. 
  • Extremely lightweight and fast-loading. 
  • Declarative API for easily adding complex animations to React components. 

Here is a list of the best Swift/iOS animation libraries for 2023 that developers can use to create immersive animations for mobile app development.


Animations can make a huge difference in user experience. Animation Libraries are a great way to add dynamic animations to the app. Correctly implemented, functional, beautiful animations are a joy for users and will help keep them engaged in the app. These libraries cover everything from user interface design to app analytics in a way that makes it very easy to implement animation in projects.


We have curated a list of the ten best Swift/iOS animation libraries that each provide a unique function.

Lottie-web 

  • Useful in adding animated icons and illustrations.
  • Helps load animations.
  • Helps in animated backgrounds.

react-motion 

  • Allows beautiful animations and transitions with a simple syntax.
  • Customizes the timing and duration of animations.
  • Helps in creating complex animations and transitions with ease.

Hero 

  • Helpful in custom navigation transitions.
  • Helps in creating interactive animations when tapping on views.
  • Helps in creating personalized presentation transitions.

SkeletonView 

  • Represents the structure of the UI.
  • Helps in customizing the look of the skeleton screens.
  • Creates empty screen animations.

ViewAnimator

  • Helps in animating views with ease.
  • Allows customizable animations with different directions, delays, and durations.
  • Helps in combining multiple animations for complex effects.

SwiftMessages

  • Allows custom in-app notifications to come up with animations.
  • Allows customizable designs for alerts and banners.
  • Shows toast notifications.

LiquidLoader.

  • Creates a Fun, liquid-style loading animation.
  • Allows customizable animations with different colors and shapes.
  • Helps in modifying loading animations for buttons and UI elements.

AnimatedCollectionViewLayout 

  • Customizes the animation style and direction.
  • Helps in supporting different types of cells.
  • Creates 3D effects.

LNZCollectionLayouts 

  • Has custom collection view layouts for unique designs.
  • Allows supporting different layout styles, such as circular and spiral.
  • Provides dynamic resizing and animation of cells.

Shimmer

  • Helpful in table view and collection view loading animations.
  • Used for empty screen placeholder animations.
  • Mimics the look of reflective surfaces.

Here are some of the Android Animation Libraries. Some of the use cases of Android Animation Libraries include Creating complex UI elements, enhancing user experience, enhancing game development, and Creating app-specific animations. 


Android Animation Libraries are collections of code libraries and tools for creating and animating graphics for Android applications. The libraries include a variety of animation techniques, such as keyframing, and physics-based animation, which can be used to create dynamic and interactive visual elements. 


Let us look at the libraries in detail below. 

rebound 

  • Uses a spring physics model to create animations. 
  • Designed to be used with the Android UI toolkit. 
  • Highly customizable. 

lottie-android 

  • Highly efficient and supports vector-based animations. 
  • Compatible with both Android and iOS devices. 
  • Allows you to create complex animations with a few simple lines of code

Android-Animation-Set 

  • Has no bugs, has no vulnerabilities. 
  • Has a Permissive License and it has medium support. 
  • Used in Telecommunications, Media, Telecom, User Interface, Animation applications. 

recyclerview-animators 

  • Uses less memory and fewer resources than other animation libraries. 
  • Allows you to tweak and customize the animations to suit your needs.  
  • Has built-in support for a range of animations, including alpha, translate, rotation, and more.  

ViewAnimator 

  • Allows developers to mix and match different animations to create complex effects.   
  • Has excellent documentation and a wide range of tutorials available. 
  • Animations created can be reused in multiple activities or applications. 

Swirl 

  • Doesn’t require a lot of setups and is easy to use.  
  • Provides a wide range of customization options.  
  • Has a powerful timeline feature that enables developers to animate objects across a timeline in a single line of code. 

Animated-icons 

  • Require less memory than many other animation libraries, making them ideal for mobile applications. 
  • Have a smaller code base than most other animation libraries. 
  • Are designed to be responsive, so they will resize and adapt to different screen sizes.

RxAnimation 

  • Create animations that span multiple platforms, including iOS and Windows. 
  • Able to create animations that are synchronized with user input.  
  • Allows developers to create custom animations according to their specific needs.  

React is a well-known JavaScript toolkit to generate reusable UI components that may be combined to create intricate and dynamic online apps. JavaScript is a popular programming language for developing interactive and dynamic web experiences. It is the fundamental language of the internet, and all current web browsers support it.  

Web apps are frequently created using a combination of React and JavaScript. React uses JavaScript to create and modify the user interface (UI), manage user interactions, and update the React components. Using the strength of React and the adaptability of JavaScript, you can do this to develop rich and interactive online applications. Framer Motion is a popular open-source animation library for React. It offers a straightforward and clear API for developing animations and gesture-based interactions in React and is built on top of the well-known animation library React-Spring.  

Framer Motion has several vital features, including natural gesture-based interactions, a simple and declarative API, automatic animations, server-side rendering, and more.  

This example shows how easy it is to create a slideshow effect with Framer Motion. 



PS: Preview of the output that you will get on running this code from your IDE

Code

In this solution we use the AnimatePresence tag in the react application to achieve it.

  1. Copy the code using the "Copy" button above, and paste it in a react project in your IDE.
  2. Run the application to see a timer which runs with a slideshow effect.


Note that any element can be used inside the motion tag, which will be animated.


I found this code snippet by searching for "Slideshow effect" in kandi. You can try any such use case!

Dependent Libraries

If you do not have react application that is required to run this code, you can install it by clicking on the above link of react page in kandi.

You can search for any dependent library on kandi like React.

Environment Tested

I tested this solution in the following versions. Be mindful of changes when working with other versions.

  1. The solution is created in react v18.2.0 and framer motion v6.2.4
  2. The solution is tested on chrome browser on codesandbox.io

Support

  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

Angular Animation Libraries are used for animation-related resources designed for the Angular Framework. Angular Animation Libraries for different processes like Animation Data Visualization and Page Transitions.


These libraries include pre-built animation effects, transitions, and elements. These libraries offer various features for creating engaging and interactive user interfaces. They use a declarative syntax for defining animations, doing reading, and understanding the code easier. Angular animation libraries offer advanced features like SVG, 3D animations, and parallax scrolling. It can be used for creating complex and dynamic user interfaces. It provides interactivity features like click and hover animations. It creates more engagement and interaction. 


Here is a list of handpicked top 9 Angular Animation Libraries of 2023 for your reference:

tsparticles:

  • Is a lightweight JavaScript library that we can use to create particle animations. 
  • Offers an effortless way for adding particle effects to web applications with a focus on flexibility and performance. 
  • Allows customization the particle animations like particle shape, size, density, speed, and color.
  • Making it easy to create a unique and visually appealing particle effect that matches the design and UI goals. 

rxviz:

  • Is a web-based reactive programming framework that visualizes the behavior of RxJS Observables. 
  • Is a popular library for reactive programming in JavaScript and is used in Angular applications. 
  • Offers a graphical representation of Observable streams to visualize how data flows through the application.
  • Making it easy to identify issues and optimize the application behavior. 

angular-scroll:

  • Is an Angular library that offers smooth scrolling animations for web applications.
  • Allows developers to create scrolling animations that smoothly transition between different application sections. 
  • Offers an effortless way to create anchor links that scroll to a specific application section
  • Allows users to navigate to various sections without manually scrolling through the content. 
  • Can create smooth scrolling animations to enhance web applications' visual appeal and UI.

angularjs-slider:

  • Is a library that offers a customizable range slider for AngularJS applications. 
  • Allows developers to create range sliders.
  • Allow users to select a range of values within a defined set, like choosing a range of prices or dates. 
  • Offers a range of customization options that will help developers fine-tune their slider to match the design and UI goals.

ngAnimate:

  • Is a built-in Angular library that offers support for animations in Angular applications.
  • Allows developers to create animations by changing the application state. 
  • Is built into Angular, which makes it easy to add animations to existing applications.
  • Create a new application with built-in animation features. 

delighters:

  • Is an Angular library that offers a straightforward way to add subtle and engaging animations to web pages. 
  • Allows developers to create animations triggered as the user scrolls through the page.
  • Offering a more dynamic and engaging UI. 
  • Is a lightweight library that has minimal impact on the overall performance of the web application. 

angular-svg-round-progressbar:

  • Is an Angular library that offers a circular, customizable progress bar using SVG graphics. 
  • Allows developers to create circular progress, which shows the progress of an ongoing process.
  • Offering a visual cue for users of the application status. 
  • Offers various options to fine-tune the progress bar to match the application's design and user experience goals.

ngx-spinner:

  • Allows developers to customize the loading spinners with diverse options like size, style, and color.
  • Making it easier to create loading spinners that match the design and UI goals. 
  • Can be integrated with different web technologies like React, vanilla JavaScript, and Angular.
  • Making it easier to add loading spinners to the current web applications or create new ones. 
  • Is designed to be accessible with support for screen readers and keyboard navigation.
  • Ensuring users can navigate and interact with the application.

angular-spinner:

  • Is an Angular library that provides an effortless way to add loading spinners for web applications. 
  • Allows developers to create loading spinners that appear if data is fetched or processed.
  • Providing a visual cue to users which application is working. 
  • Offers multiple spinner types, like spinner dots and lines.
  • Allowing developers to choose the spinner type that best fits the application's design and user interface goals.

Python visualization and animation libraries are modules or packages that allow you to create animations, charts, and other graphics using Python code. They usually provide functions or classes that help you manipulate graphical elements such as shapes, colors, images, text, etc., and control their movement, appearance, and behavior over time. Some examples of Python animation libraries are Matplotlib, VPython, and manim.



Python animation libraries are useful for creating dynamic and interactive visualizations of data or objects using Python code. For example, you can use Matplotlib to plot graphs of functions or figures and add animations to them. You can also use VPython to create 3D displays and animations of physical phenomena. Another example is manim, an animation library designed for an intuitive and easy-to-use interface and for explanatory math videos used for programmatically creating precise animations.


Python itself cannot create animation. It can only create images. It needs an external program to create a perception of movement. Python animation libraries may have specific requirements or caveats for creating animations. For example, celluloid requires that the axes limits are the same for all plots and that artists are passed to the legend function separately Plotly has some limitations with 3D animations and interactivity.


Here are some of the top open source Python animation libraries you can leverage in your projects.

Animation is the craft of making inanimate objects appear to move. It is a method by which still figures are manipulated to appear as moving images.


Pygame is a Python module set designed for composing video games. It is written on top of the perfect SDL library. This will allow you to create fully featured multimedia programs and games in Python. Pygame is highly portable and will run on nearly every platform and operating system. 

  • There are different ways to create animations in Pygame, such as sprites and character animation.


Here is an example of creating and displaying simple animations in Pygame.




Fig1: Preview of the Code



Fig2: Preview of Output when the code is run in IDE.

Code


In this solution, we are creating and displaying simple animations using Pygame

Instructions

Follow the steps carefully to get the output easily.

  1. Install Jupyter Notebook on your computer.
  2. Open terminal and install the required libraries with following commands.
  3. Install pygame - pip install pygame.
  4. Copy the code using the "Copy" button above, and paste it into your IDE's Python file.
  5. Run the file to get the desired output.


I hope you found this useful. I have added the link to dependent libraries, version information in the following sections.


I found this code snippet by searching for "Text animations in pygame" in kandi. You can try any such use case!

Dependent Libraries


If you do not have Pygame that is required to run this code, you can install it by clicking on the above link and copying the pip Install command from the Pygame page in kandi.


You can search for any dependent library on kandi like pygame.

Environment Tested


I tested this solution in the following versions. Be mindful of changes when working with other versions.

  1. The solution is created in Python 3.9.6
  2. The solution is tested on pygame version 2.3.0


Using this solution, we are able to create and display simple animations using Pygame.

Support

  1. For any support on kandi solution kits, please use the chat
  2. For further learning resources, visit the Open Weaver Community learning page.

Animation Is Continuous and Have smooth Flow By DEVELOVERS

EXAMPLE Of Demo

Create Folder In Root Directory Name As :- Components

1) Name Below Given File As :- BackgroundAnimation.js And Save It in Within Components Folder

import React, { useEffect,useRef } from 'react';
import { Animated, Easing, ImageBackground } from 'react-native';
import backgroundImage from '../res/Background.jpg'
import styles from './styles';
import {
  INPUT_RANGE_START, 
  INPUT_RANGE_END,
  OUTPUT_RANGE_START,
  OUTPUT_RANGE_END,
  ANIMATION_TO_VALUE,
  ANIMATION_DURATION,
} from './constants';


export default function BackgroundAnimation() {
  const initialValue = 0;
  const translateValue = useRef(new Animated.Value(initialValue)).current;


  useEffect(() => {
    const translate = () => {
      translateValue.setValue(initialValue);
      Animated.timing(translateValue, {
        toValue: ANIMATION_TO_VALUE,
        duration: ANIMATION_DURATION,
        easing: Easing.linear,
        useNativeDriver: true,
      }).start(() => translate());
    };


    translate();
  }, [translateValue]);


  const translateAnimation = translateValue.interpolate({
    inputRange: [INPUT_RANGE_START, INPUT_RANGE_END],
    outputRange: [OUTPUT_RANGE_START, OUTPUT_RANGE_END],
  });


  const AnimetedImage = Animated.createAnimatedComponent(ImageBackground);


  return (
    
        <AnimetedImage 
            resizeMode="repeat" 
            style={[styles.background,{
                transform: [
                    {
                      translateX: translateAnimation,
                    },
                    {
                      translateY: translateAnimation,
                    },
                  ],
            }]}
            source={backgroundImage} />
  )
}

2) Name Below Given File As :- styles.js , And Save It in Within Components Folder

import {StyleSheet} from 'react-native'


const styles = StyleSheet.create({    
    
    background: {
        position: 'absolute',
        width: 1200,
        height: 1200,
        top: 0,
  // Set Fadeness  On Image Using Prop Given below
        opacity: 0.15, 
        transform: [
          {
            translateX: 0,
          },
          {
            translateY: 0,
          },
        ],      
      }, 
  });


export default styles

3) Name Below Given File As :- constants.js , And Save It in Within Components Folder

export const INPUT_RANGE_START = 0;
export const INPUT_RANGE_END = 1;
export const OUTPUT_RANGE_START = -281;
export const OUTPUT_RANGE_END = 0;
export const ANIMATION_TO_VALUE = 1;
export const ANIMATION_DURATION = 25000;

Save Image To Directory Named as res Available In Root Directory

Name You Image Background.jpg

../res/Background.jpg

IMAGE SIZE :

4) When You are done With All 3 Files, Now You Just Need To Import It And Call Within That Page

Let's Have A Look on An Example

I am Gonna set It for Login Screen Background:

import React, { useCallback, useEffect, useState } from "react";
import {StatusBar, View, Text, TextInput, Image,StyleSheet, TouchableOpacity, Alert, ActivityIndicator, Keyboard } from "react-native";
import { validate } from "react-email-validator";
import auth from '@react-native-firebase/auth';


        // Import The Given Below File
import BackgroundAnimation from '../Components/BackgroundAnimation';


const Login = ({route , navigation}) => {


    return(
        // this Should Must be Flex 1 And NO Background color or background Image Props
        <View style={{flex:1}}>
            <StatusBar backgroundColor="#0a2e2c"/>
        {/* This Is the Point Where You Should Call That, As Mentioned */}
            <BackgroundAnimation/>


            <View style={styles.CentreLogo}>

If This Finds You help Full

Follow Me On GitHub As Well :

Have you ever wanted to be represented by an avatar in virtual reality? Are you looking to make a game or app that uses avatars in Javascript, Typescript, or PHP? Avatars are digital representations of people, pets, or entities. They're widely used in VR games and apps, and they're also becoming popular in the Metaverse—a unified digital space where people can meet, interact, and create things together. Avatar technology has been around for a long time—it's not new. But with the increasing popularity of the Metaverse, it is becoming more popular than ever. There are many different ways to use avatars. They can be used for all types of virtual experiences, including games and education apps. For example, you could create a game where you have to find your way through a maze using an avatar. Or, you could create an educational app where you have to find your way through a maze using an avatar. In the Metaverse and in VR gaming, avatars are more than just characters—they're extensions of ourselves. Many people jump into both the physical and virtual world wearing their best heels. Some gamers wear full-body suits to help them truly embody their avatars. Most avatars are animated by code—here are some popular open-source libraries you can use to create and use avatars.

Trending Discussions on Animation

AngularFireModule and AngularFireDatabaseModule not being found in @angular/fire

Marquee Text Effect in Jetpack Compose

android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported

Error importing Framer Motion v5 in React (with create-react-app)

Android Build Error: &quot;lStar not found...&quot;

Make ModalBottomSheetLayout always Expanded

Project update recommended: Android Gradle Plugin can be upgraded. Error message: Can not find AGP version in build files

Angular TSLint - Cannot find builder &quot;@angular-devkit/build-angular:tslint&quot;

SVG stop running chained animation (&lt;animate&gt; tag)

How to replace deprecated .animation() in SwiftUI?

QUESTION

AngularFireModule and AngularFireDatabaseModule not being found in @angular/fire

Asked 2022-Apr-01 at 12:56

I am trying to implement Firebase Realtime Database into a angular project and Im getting stuck at one of the very first steps. Importing AngularFireModule and AngularFireDatabaseModule. It gives me the following error:

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2
1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3

And here is how I am importing them:

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3import {AngularFireModule } from '@angular/fire';
4import {AngularFireDatabaseModule} from '@angular/fire/database'
5

Am I missing something here? I have installed @angular/fire via the command

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3import {AngularFireModule } from '@angular/fire';
4import {AngularFireDatabaseModule} from '@angular/fire/database'
5npm i firebase @angular/fire
6

and have also installed firebase tools. Here is a list of the Angular packages I currently have installed and their versions:

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3import {AngularFireModule } from '@angular/fire';
4import {AngularFireDatabaseModule} from '@angular/fire/database'
5npm i firebase @angular/fire
6Angular CLI: 12.2.2
7Node: 14.17.4
8Package Manager: npm 6.14.14
9OS: win32 x64
10
11Angular: 12.2.3
12... animations, common, compiler, compiler-cli, core, forms
13... platform-browser, platform-browser-dynamic, router
14
15Package                         Version
16---------------------------------------------------------
17@angular-devkit/architect       0.1202.2
18@angular-devkit/build-angular   12.2.2
19@angular-devkit/core            12.2.2
20@angular-devkit/schematics      12.2.2
21@angular/cli                    12.2.2
22@angular/fire                   7.0.0
23@schematics/angular             12.2.2
24rxjs                            6.6.7
25typescript                      4.3.5
26

I do apologise if this is all excessive information but I am completely stuck as to what the issue is. Any help would be GREATLY appreciated. Right now my suspicion is that its a compatibility issue or perhaps a feature that doesnt exist anymore on the latest versions but I really dont know.

ANSWER

Answered 2021-Aug-26 at 13:20

AngularFire 7.0.0 was launched yesterday with a new API that has a lot of bundle size reduction benefits.

Instead of top level classes like AngularFireDatabase, you can now import smaller independent functions.

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3import {AngularFireModule } from '@angular/fire';
4import {AngularFireDatabaseModule} from '@angular/fire/database'
5npm i firebase @angular/fire
6Angular CLI: 12.2.2
7Node: 14.17.4
8Package Manager: npm 6.14.14
9OS: win32 x64
10
11Angular: 12.2.3
12... animations, common, compiler, compiler-cli, core, forms
13... platform-browser, platform-browser-dynamic, router
14
15Package                         Version
16---------------------------------------------------------
17@angular-devkit/architect       0.1202.2
18@angular-devkit/build-angular   12.2.2
19@angular-devkit/core            12.2.2
20@angular-devkit/schematics      12.2.2
21@angular/cli                    12.2.2
22@angular/fire                   7.0.0
23@schematics/angular             12.2.2
24rxjs                            6.6.7
25typescript                      4.3.5
26import { list } from '@angular/fire/database';
27

The initialization process is a bit different too as it has a more flexible API for specifying configurations.

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3import {AngularFireModule } from '@angular/fire';
4import {AngularFireDatabaseModule} from '@angular/fire/database'
5npm i firebase @angular/fire
6Angular CLI: 12.2.2
7Node: 14.17.4
8Package Manager: npm 6.14.14
9OS: win32 x64
10
11Angular: 12.2.3
12... animations, common, compiler, compiler-cli, core, forms
13... platform-browser, platform-browser-dynamic, router
14
15Package                         Version
16---------------------------------------------------------
17@angular-devkit/architect       0.1202.2
18@angular-devkit/build-angular   12.2.2
19@angular-devkit/core            12.2.2
20@angular-devkit/schematics      12.2.2
21@angular/cli                    12.2.2
22@angular/fire                   7.0.0
23@schematics/angular             12.2.2
24rxjs                            6.6.7
25typescript                      4.3.5
26import { list } from '@angular/fire/database';
27@NgModule({
28    imports: [
29        provideFirebaseApp(() =&gt; initializeApp(config)),
30        provideFirestore(() =&gt; {
31            const firestore = getFirestore();
32            connectEmulator(firestore, 'localhost', 8080);
33            enableIndexedDbPersistence(firestore);
34            return firestore;
35        }),
36        provideStorage(() =&gt; getStorage()),
37    ],
38})
39

If you want to proceed with the older API there's a compatibility layer.

1Module '&quot;@angular/fire&quot;' has no exported member 'AngularFireModule'.ts(2305)
2Module '&quot;@angular/fire/database&quot;' has no exported member 'AngularFireDatabaseModule'.
3import {AngularFireModule } from '@angular/fire';
4import {AngularFireDatabaseModule} from '@angular/fire/database'
5npm i firebase @angular/fire
6Angular CLI: 12.2.2
7Node: 14.17.4
8Package Manager: npm 6.14.14
9OS: win32 x64
10
11Angular: 12.2.3
12... animations, common, compiler, compiler-cli, core, forms
13... platform-browser, platform-browser-dynamic, router
14
15Package                         Version
16---------------------------------------------------------
17@angular-devkit/architect       0.1202.2
18@angular-devkit/build-angular   12.2.2
19@angular-devkit/core            12.2.2
20@angular-devkit/schematics      12.2.2
21@angular/cli                    12.2.2
22@angular/fire                   7.0.0
23@schematics/angular             12.2.2
24rxjs                            6.6.7
25typescript                      4.3.5
26import { list } from '@angular/fire/database';
27@NgModule({
28    imports: [
29        provideFirebaseApp(() =&gt; initializeApp(config)),
30        provideFirestore(() =&gt; {
31            const firestore = getFirestore();
32            connectEmulator(firestore, 'localhost', 8080);
33            enableIndexedDbPersistence(firestore);
34            return firestore;
35        }),
36        provideStorage(() =&gt; getStorage()),
37    ],
38})
39import { AngularFireModule} from '@angular/fire/compat'
40import { AngularFireDatabaseModule } from '@angular/fire/compat/database';
41

Source https://stackoverflow.com/questions/68939014

QUESTION

Marquee Text Effect in Jetpack Compose

Asked 2022-Mar-30 at 10:05

In the past, a kind of animation could be included in the text, in which if the text exceeded the limits, it would automatically scroll horizontally. This was done by including: android:ellipsize="marquee", and the result was something similar to the one shown here:

enter image description here

The problem is that in Jetpack Compose I don't see a way to include that option inside the Composable Text, there is the TextOverflow that includes the Clip, Ellipsis or Visible options, but I don't know if there is a way to include or use the "Marquee" option in Jetpack Compose. Is there any way to do it?

ANSWER

Answered 2022-Mar-30 at 10:05

This is not yet supported by Compose, but it's not too hard to implement. You will need TargetBasedAnimation, which will update the text offset, and SubcomposeLayout, which lies under most collections. Inside you can define the size of the text, and also place the second similar Text, which will appear from the right edge.

1@Composable
2fun MarqueeText(
3    text: String,
4    modifier: Modifier = Modifier,
5    textModifier: Modifier = Modifier,
6    gradientEdgeColor: Color = Color.White,
7    color: Color = Color.Unspecified,
8    fontSize: TextUnit = TextUnit.Unspecified,
9    fontStyle: FontStyle? = null,
10    fontWeight: FontWeight? = null,
11    fontFamily: FontFamily? = null,
12    letterSpacing: TextUnit = TextUnit.Unspecified,
13    textDecoration: TextDecoration? = null,
14    textAlign: TextAlign? = null,
15    lineHeight: TextUnit = TextUnit.Unspecified,
16    overflow: TextOverflow = TextOverflow.Clip,
17    softWrap: Boolean = true,
18    onTextLayout: (TextLayoutResult) -&gt; Unit = {},
19    style: TextStyle = LocalTextStyle.current,
20) {
21    val createText = @Composable { localModifier: Modifier -&gt;
22        Text(
23            text,
24            textAlign = textAlign,
25            modifier = localModifier,
26            color = color,
27            fontSize = fontSize,
28            fontStyle = fontStyle,
29            fontWeight = fontWeight,
30            fontFamily = fontFamily,
31            letterSpacing = letterSpacing,
32            textDecoration = textDecoration,
33            lineHeight = lineHeight,
34            overflow = overflow,
35            softWrap = softWrap,
36            maxLines = 1,
37            onTextLayout = onTextLayout,
38            style = style,
39        )
40    }
41    var offset by remember { mutableStateOf(0) }
42    val textLayoutInfoState = remember { mutableStateOf&lt;TextLayoutInfo?&gt;(null) }
43    LaunchedEffect(textLayoutInfoState.value) {
44        val textLayoutInfo = textLayoutInfoState.value ?: return@LaunchedEffect
45        if (textLayoutInfo.textWidth &lt;= textLayoutInfo.containerWidth) return@LaunchedEffect
46        val duration = 7500 * textLayoutInfo.textWidth / textLayoutInfo.containerWidth
47        val delay = 1000L
48
49        do {
50            val animation = TargetBasedAnimation(
51                animationSpec = infiniteRepeatable(
52                    animation = tween(
53                        durationMillis = duration,
54                        delayMillis = 1000,
55                        easing = LinearEasing,
56                    ),
57                    repeatMode = RepeatMode.Restart
58                ),
59                typeConverter = Int.VectorConverter,
60                initialValue = 0,
61                targetValue = -textLayoutInfo.textWidth
62            )
63            val startTime = withFrameNanos { it }
64            do {
65                val playTime = withFrameNanos { it } - startTime
66                offset = (animation.getValueFromNanos(playTime))
67            } while (!animation.isFinishedFromNanos(playTime))
68            delay(delay)
69        } while (true)
70    }
71
72    SubcomposeLayout(
73        modifier = modifier.clipToBounds()
74    ) { constraints -&gt;
75        val infiniteWidthConstraints = constraints.copy(maxWidth = Int.MAX_VALUE)
76        var mainText = subcompose(MarqueeLayers.MainText) {
77            createText(textModifier)
78        }.first().measure(infiniteWidthConstraints)
79
80        var gradient: Placeable? = null
81
82        var secondPlaceableWithOffset: Pair&lt;Placeable, Int&gt;? = null
83        if (mainText.width &lt;= constraints.maxWidth) {
84            mainText = subcompose(MarqueeLayers.SecondaryText) {
85                createText(textModifier.fillMaxWidth())
86            }.first().measure(constraints)
87            textLayoutInfoState.value = null
88        } else {
89            val spacing = constraints.maxWidth * 2 / 3
90            textLayoutInfoState.value = TextLayoutInfo(
91                textWidth = mainText.width + spacing,
92                containerWidth = constraints.maxWidth
93            )
94            val secondTextOffset = mainText.width + offset + spacing
95            val secondTextSpace = constraints.maxWidth - secondTextOffset
96            if (secondTextSpace &gt; 0) {
97                secondPlaceableWithOffset = subcompose(MarqueeLayers.SecondaryText) {
98                    createText(textModifier)
99                }.first().measure(infiniteWidthConstraints) to secondTextOffset
100            }
101            gradient = subcompose(MarqueeLayers.EdgesGradient) {
102                Row {
103                    GradientEdge(gradientEdgeColor, Color.Transparent)
104                    Spacer(Modifier.weight(1f))
105                    GradientEdge(Color.Transparent, gradientEdgeColor)
106                }
107            }.first().measure(constraints.copy(maxHeight = mainText.height))
108        }
109
110        layout(
111            width = constraints.maxWidth,
112            height = mainText.height
113        ) {
114            mainText.place(offset, 0)
115            secondPlaceableWithOffset?.let {
116                it.first.place(it.second, 0)
117            }
118            gradient?.place(0, 0)
119        }
120    }
121}
122
123@Composable
124private fun GradientEdge(
125    startColor: Color, endColor: Color,
126) {
127    Box(
128        modifier = Modifier
129            .width(10.dp)
130            .fillMaxHeight()
131            .background(
132                brush = Brush.horizontalGradient(
133                    0f to startColor, 1f to endColor,
134                )
135            )
136    )
137}
138
139private enum class MarqueeLayers { MainText, SecondaryText, EdgesGradient }
140private data class TextLayoutInfo(val textWidth: Int, val containerWidth: Int)
141

Usage:

1@Composable
2fun MarqueeText(
3    text: String,
4    modifier: Modifier = Modifier,
5    textModifier: Modifier = Modifier,
6    gradientEdgeColor: Color = Color.White,
7    color: Color = Color.Unspecified,
8    fontSize: TextUnit = TextUnit.Unspecified,
9    fontStyle: FontStyle? = null,
10    fontWeight: FontWeight? = null,
11    fontFamily: FontFamily? = null,
12    letterSpacing: TextUnit = TextUnit.Unspecified,
13    textDecoration: TextDecoration? = null,
14    textAlign: TextAlign? = null,
15    lineHeight: TextUnit = TextUnit.Unspecified,
16    overflow: TextOverflow = TextOverflow.Clip,
17    softWrap: Boolean = true,
18    onTextLayout: (TextLayoutResult) -&gt; Unit = {},
19    style: TextStyle = LocalTextStyle.current,
20) {
21    val createText = @Composable { localModifier: Modifier -&gt;
22        Text(
23            text,
24            textAlign = textAlign,
25            modifier = localModifier,
26            color = color,
27            fontSize = fontSize,
28            fontStyle = fontStyle,
29            fontWeight = fontWeight,
30            fontFamily = fontFamily,
31            letterSpacing = letterSpacing,
32            textDecoration = textDecoration,
33            lineHeight = lineHeight,
34            overflow = overflow,
35            softWrap = softWrap,
36            maxLines = 1,
37            onTextLayout = onTextLayout,
38            style = style,
39        )
40    }
41    var offset by remember { mutableStateOf(0) }
42    val textLayoutInfoState = remember { mutableStateOf&lt;TextLayoutInfo?&gt;(null) }
43    LaunchedEffect(textLayoutInfoState.value) {
44        val textLayoutInfo = textLayoutInfoState.value ?: return@LaunchedEffect
45        if (textLayoutInfo.textWidth &lt;= textLayoutInfo.containerWidth) return@LaunchedEffect
46        val duration = 7500 * textLayoutInfo.textWidth / textLayoutInfo.containerWidth
47        val delay = 1000L
48
49        do {
50            val animation = TargetBasedAnimation(
51                animationSpec = infiniteRepeatable(
52                    animation = tween(
53                        durationMillis = duration,
54                        delayMillis = 1000,
55                        easing = LinearEasing,
56                    ),
57                    repeatMode = RepeatMode.Restart
58                ),
59                typeConverter = Int.VectorConverter,
60                initialValue = 0,
61                targetValue = -textLayoutInfo.textWidth
62            )
63            val startTime = withFrameNanos { it }
64            do {
65                val playTime = withFrameNanos { it } - startTime
66                offset = (animation.getValueFromNanos(playTime))
67            } while (!animation.isFinishedFromNanos(playTime))
68            delay(delay)
69        } while (true)
70    }
71
72    SubcomposeLayout(
73        modifier = modifier.clipToBounds()
74    ) { constraints -&gt;
75        val infiniteWidthConstraints = constraints.copy(maxWidth = Int.MAX_VALUE)
76        var mainText = subcompose(MarqueeLayers.MainText) {
77            createText(textModifier)
78        }.first().measure(infiniteWidthConstraints)
79
80        var gradient: Placeable? = null
81
82        var secondPlaceableWithOffset: Pair&lt;Placeable, Int&gt;? = null
83        if (mainText.width &lt;= constraints.maxWidth) {
84            mainText = subcompose(MarqueeLayers.SecondaryText) {
85                createText(textModifier.fillMaxWidth())
86            }.first().measure(constraints)
87            textLayoutInfoState.value = null
88        } else {
89            val spacing = constraints.maxWidth * 2 / 3
90            textLayoutInfoState.value = TextLayoutInfo(
91                textWidth = mainText.width + spacing,
92                containerWidth = constraints.maxWidth
93            )
94            val secondTextOffset = mainText.width + offset + spacing
95            val secondTextSpace = constraints.maxWidth - secondTextOffset
96            if (secondTextSpace &gt; 0) {
97                secondPlaceableWithOffset = subcompose(MarqueeLayers.SecondaryText) {
98                    createText(textModifier)
99                }.first().measure(infiniteWidthConstraints) to secondTextOffset
100            }
101            gradient = subcompose(MarqueeLayers.EdgesGradient) {
102                Row {
103                    GradientEdge(gradientEdgeColor, Color.Transparent)
104                    Spacer(Modifier.weight(1f))
105                    GradientEdge(Color.Transparent, gradientEdgeColor)
106                }
107            }.first().measure(constraints.copy(maxHeight = mainText.height))
108        }
109
110        layout(
111            width = constraints.maxWidth,
112            height = mainText.height
113        ) {
114            mainText.place(offset, 0)
115            secondPlaceableWithOffset?.let {
116                it.first.place(it.second, 0)
117            }
118            gradient?.place(0, 0)
119        }
120    }
121}
122
123@Composable
124private fun GradientEdge(
125    startColor: Color, endColor: Color,
126) {
127    Box(
128        modifier = Modifier
129            .width(10.dp)
130            .fillMaxHeight()
131            .background(
132                brush = Brush.horizontalGradient(
133                    0f to startColor, 1f to endColor,
134                )
135            )
136    )
137}
138
139private enum class MarqueeLayers { MainText, SecondaryText, EdgesGradient }
140private data class TextLayoutInfo(val textWidth: Int, val containerWidth: Int)
141MarqueeText(&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt&quot;)
142

Result:

Source https://stackoverflow.com/questions/68974245

QUESTION

android:exported added but still getting error Apps targeting Android 12 and higher are required to specify an explicit value for android:exported

Asked 2022-Mar-24 at 15:30

I have added android:exported="true" to my only activity in manifest but still getting below error after updating compile sdk and target sdk version to 31.I also tried rebuilding the project , invalidating cache and restart but that didn't helped

Error- Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

AndroidManifest File
1&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
2&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
3    package=&quot;com.xyz.abc&quot;&gt;
4
5    &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
6    &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
7
8    &lt;application
9        android:name=&quot;.framework.presentation.BaseApplication&quot;
10        android:allowBackup=&quot;true&quot;
11        android:icon=&quot;@mipmap/ic_launcher&quot;
12        android:label=&quot;@string/app_name&quot;
13        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
14        android:supportsRtl=&quot;true&quot;
15        android:theme=&quot;@style/AppTheme&quot;&gt;
16        &lt;activity android:name=&quot;com.xyz.presentation.MainActivity&quot;
17            android:exported=&quot;true&quot;&gt;
18            &lt;intent-filter&gt;
19                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
20
21                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
22            &lt;/intent-filter&gt;
23        &lt;/activity&gt;
24    &lt;/application&gt;
25
26&lt;/manifest&gt;
27
Merged manifest error

Other Manifest Files (Included in merge, but did not contribute any elements) firebase-installations:17.0.0 manifest, versionedparcelable:1.1.1 manifest, runtime:1.0.1 manifest, test:core:1.2.0 manifest, loader:1.0.0 manifest, facebook-share:11.1.0 manifest, leakcanary:leaksentry:2.0-alpha-3 manifest, material-dialogs:input:3.2.1 manifest, material-icons-extended:1.0.0 manifest, play-services-stats:17.0.0 manifest, interpolator:1.0.0 manifest, activity-compose:1.3.1 manifest, material-ripple:1.0.0 manifest, foundation:1.0.0 manifest, asynclayoutinflater:1.0.0 manifest, savedstate-ktx:1.1.0 manifest, navigation-dynamic-features-fragment:2.3.5 manifest, firebase-ui-auth:7.2.0 manifest, animation:1.0.1 manifest, animation-core:1.0.1 manifest, installreferrer:1.0 manifest, firebase-crashlytics:18.0.0 manifest, ui:1.0.1 manifest, lifecycle-viewmodel-savedstate:2.3.1 manifest, play-services-auth-base:17.0.0 manifest, hilt-android:2.35.1 manifest, material-dialogs:core:3.2.1 manifest, AndroidManifest.xml navigation file, savedstate:1.1.0 manifest, cursoradapter:1.0.0 manifest, sqlite-framework:2.0.1 manifest, room-ktx:2.1.0 manifest, leakcanary-android-core:2.0-alpha-3 manifest, AndroidManifest.xml navigation file, media:1.0.0 manifest, coordinatorlayout:1.1.0 manifest, legacy-support-core-utils:1.0.0 manifest, lifecycle-runtime:2.3.1 manifest, coil-kt:coil:1.3.1 manifest, ui-tooling-preview:1.0.0 manifest, facebook-core:11.1.0 manifest, core:1.6.0 manifest, material:1.0.0 manifest, firebase-common:20.0.0 manifest, documentfile:1.0.0 manifest, lifecycle-viewmodel-compose:2.4.0-beta01 manifest, play-services-base:17.1.0 manifest, ui-tooling-data:1.0.0 manifest, coil-base:1.3.1 manifest, firebase-analytics-ktx:19.0.0 manifest, localbroadcastmanager:1.0.0 manifest, swiperefreshlayout:1.1.0-alpha03 manifest, constraintlayout-compose:1.0.0-beta02 manifest, core-ktx:1.6.0 manifest, firebase-database-collection:18.0.0 manifest, coil-compose-base:1.3.1 manifest, activity:1.3.1 manifest, AndroidManifest.xml navigation file, facebook-messenger:11.1.0 manifest, print:1.0.0 manifest, customview:1.1.0 manifest, material-icons-core:1.0.0 manifest, play-services-measurement-sdk:19.0.0 manifest, fragment:1.3.4 manifest, firebase-appcheck-interop:16.0.0-beta01 manifest, facebook-login:11.1.0 manifest, cardview:1.0.0 manifest, runtime-rxjava2:1.0.0 manifest, viewpager2:1.0.0 manifest, play-services-ads-identifier:17.0.0 manifest, play-services-measurement-impl:19.0.0 manifest, lifecycle-livedata-core:2.3.1 manifest, play-services-safetynet:17.0.0 manifest, AndroidManifest.xml navigation file, lifecycle-viewmodel-ktx:2.3.1 manifest, transport-backend-cct:3.0.0 manifest, fragment-ktx:1.2.4 manifest, appcompat:1.3.0 manifest, transport-runtime:3.0.0 manifest, lifecycle-livedata-core-ktx:2.2.0 manifest, firebase-firestore-ktx:23.0.0 manifest, legacy-support-v4:1.0.0 manifest, play-services-basement:17.1.1 manifest, firebase-storage:20.0.0 manifest, play-services-auth-api-phone:17.4.0 manifest, leakcanary-android:2.0-alpha-3 manifest, firebase-auth-interop:20.0.0 manifest, lifecycle-viewmodel:2.3.1 manifest, browser:1.0.0 manifest, firebase-auth:21.0.1 manifest, material:1.2.1 manifest, slidingpanelayout:1.0.0 manifest, vectordrawable:1.1.0 manifest, recyclerview:1.1.0 manifest, play-services-auth:19.0.0 manifest, room-runtime:2.1.0 manifest, dagger-lint-aar:2.35.1 manifest, navigation-dynamic-features-runtime:2.3.5 manifest, play-services-measurement-api:19.0.0 manifest, firebase-encoders-json:18.0.0 manifest, sqlite:2.0.1 manifest, facebook-android-sdk:11.1.0 manifest, firebase-components:17.0.0 manifest, transport-api:3.0.0 manifest, protolite-well-known-types:18.0.0 manifest, markdown-processor:0.1.3 manifest, play-services-measurement-base:19.0.0 manifest, firebase-common-ktx:20.0.0 manifest, activity-ktx:1.3.1 manifest, firebase-crashlytics-ktx:18.0.0 manifest, coil-compose:1.3.1 manifest, multidex:2.0.1 manifest, core-runtime:2.1.0 manifest, fragment-testing:1.2.0 manifest, ui-graphics:1.0.1 manifest, AndroidManifest.xml navigation file, ui-tooling:1.0.0 manifest, grpc-android:1.28.0 manifest, ui-unit:1.0.1 manifest, play-services-measurement:19.0.0 manifest, play:core:1.9.1 manifest, annotation-experimental:1.1.0 manifest, play-services-measurement-sdk-api:19.0.0 manifest, play-services-tasks:17.0.0 manifest, firebase-analytics:19.0.0 manifest, facebook-common:11.1.0 manifest, drawerlayout:1.1.1 manifest, AndroidManifest.xml navigation file, navigation-compose:2.4.0-alpha09 manifest, facebook-gamingservices:11.1.0 manifest, firebase-firestore:23.0.0 manifest, lifecycle-livedata:2.2.0 manifest, legacy-support-core-ui:1.0.0 manifest, test:monitor:1.2.0 manifest, AndroidManifest.xml navigation file, facebook-applinks:11.1.0 manifest, viewpager:1.0.0 manifest, ui-geometry:1.0.1 manifest, lifecycle-runtime-ktx:2.3.1 manifest, constraintlayout:2.0.4 manifest, ui-text:1.0.1 manifest, AndroidManifest.xml navigation file, firebase-installations-interop:17.0.0 manifest, transition:1.3.0 manifest, foundation-layout:1.0.1 manifest, appcompat-resources:1.3.1 manifest, runtime-livedata:1.0.0 manifest, runtime-saveable:1.0.1 manifest, firebase-measurement-connector:19.0.0 manifest, vectordrawable-animated:1.1.0 manifest, main nav_graph.xml navigation file Merging Errors: Error: android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. Dairy.app main manifest (this file) Error: android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. Dairy.app main manifest (this file) Error: android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. Dairy.app main manifest (this file)

ANSWER

Answered 2021-Oct-05 at 10:38

After the build has failed go to AndroidManifest.xml and in the bottom click merged manifest see which activities which have intent-filter but don't have exported=true attribute. Or you can just get the activities which are giving error.

Add these activities to your App manifest with android:exported="true" and app tools:node="merge" this will add exported attribute to the activities giving error.

Example:

1&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
2&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
3    package=&quot;com.xyz.abc&quot;&gt;
4
5    &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
6    &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
7
8    &lt;application
9        android:name=&quot;.framework.presentation.BaseApplication&quot;
10        android:allowBackup=&quot;true&quot;
11        android:icon=&quot;@mipmap/ic_launcher&quot;
12        android:label=&quot;@string/app_name&quot;
13        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
14        android:supportsRtl=&quot;true&quot;
15        android:theme=&quot;@style/AppTheme&quot;&gt;
16        &lt;activity android:name=&quot;com.xyz.presentation.MainActivity&quot;
17            android:exported=&quot;true&quot;&gt;
18            &lt;intent-filter&gt;
19                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
20
21                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
22            &lt;/intent-filter&gt;
23        &lt;/activity&gt;
24    &lt;/application&gt;
25
26&lt;/manifest&gt;
27      &lt;activity
28            android:name=&quot;&lt;activity which is giving error&gt;&quot;
29            android:exported=&quot;true&quot;
30            tools:node=&quot;merge&quot; /&gt;
31

You will have to do this once, you can remove this once the library developers update their libs.

Source https://stackoverflow.com/questions/69287478

QUESTION

Error importing Framer Motion v5 in React (with create-react-app)

Asked 2022-Mar-13 at 15:19

When am trying to do simple animation for div using framer motion. Am getting this following error in browser

/node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs

1Can't import the named export 'Children' from non EcmaScript module (only default export is available)```
2

ANSWER

Answered 2021-Nov-01 at 16:16

Here's the response to the issue from the Framer Discord

regarding the issue with the current version of create-react-app (CRA) the issue is being tracked on GitHub here: https://github.com/formatjs/formatjs/issues/1395

After testing a bit it seems that the issue is with how CRA handles ESM dependancies and more particularly transitive dependancies are not handled correctly it seems. There is also an outstanding issue with CRA about this https://github.com/facebook/create-react-app/issues/10356.

Options:

  1. This is fixed/doesn't break in the next version of CRA which you can try today (https://github.com/facebook/create-react-app/discussions/11278) take note though its still in alpha.

  2. You can patch CRA to get around the issue as described in a number of tickets from other libraries

Source https://stackoverflow.com/questions/69769360

QUESTION

Android Build Error: &quot;lStar not found...&quot;

Asked 2022-Feb-18 at 06:59

I have error like this after trying to build my apps in Emulator

/Users/joel/.gradle/caches/transforms-3/06231cc1265260b25a06bafce7a4176f/transformed/core-1.7.0-alpha02/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

I don't know what causes this error. After digging some answer which has similarly error (but in flutter) Problem. But still not solved my issue.

I have this dependency in my project

1buildscript {
2    repositories {
3        google()
4        maven { url 'https://plugins.gradle.org/m2/' }
5    }
6
7    dependencies {
8        classpath 'com.google.gms:google-services:4.3.3'
9        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
10    }
11}
12apply plugin: 'com.android.application'
13apply plugin: 'com.google.gms.google-services'
14apply plugin: 'kotlin-android'
15apply plugin: 'kotlin-android-extensions'
16apply plugin: 'kotlin-kapt'
17apply plugin: 'com.google.firebase.crashlytics'
18
19repositories {
20    maven { url 'https://maven.fabric.io/public' }
21    maven { url 'https://maven.google.com' }
22    maven { url  &quot;https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod&quot;}
23    mavenCentral()
24
25}
26
27android {
28    compileSdkVersion 29
29    buildToolsVersion '28.0.3'
30    defaultConfig {
31        applicationId &quot;mobile.apps.my&quot;
32        minSdkVersion 17
33        targetSdkVersion 29
34        multiDexEnabled true
35        versionCode 152
36        versionName &quot;8.1.7&quot;
37        vectorDrawables.useSupportLibrary = true // This line hereP
38        testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
39    }
40
41    compileOptions {
42        sourceCompatibility JavaVersion.VERSION_1_8
43        targetCompatibility JavaVersion.VERSION_1_8
44    }
45
46    dataBinding {
47        enabled = true
48    }
49
50    buildTypes {
51        debug {
52            firebaseCrashlytics {
53                mappingFileUploadEnabled false
54            }
55        }
56
57        release {
58            minifyEnabled true
59            shrinkResources true
60            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
61        }
62    }
63
64    lintOptions {
65        checkReleaseBuilds false
66        abortOnError false
67    }
68}
69
70dependencies {
71
72    implementation fileTree(include: ['*.jar'], dir: 'libs')
73    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0-beta01', {
74        exclude group: 'com.android.support', module: 'support-annotations'
75    })
76    //noinspection GradleCompatible
77    implementation 'androidx.appcompat:appcompat:1.4.0-alpha03'
78    implementation &quot;androidx.appcompat:appcompat-resources:1.4.0-alpha03&quot;
79
80    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
81    implementation 'androidx.preference:preference:1.1.1'
82    implementation 'com.google.android.material:material:1.4.0'
83    implementation 'androidx.recyclerview:recyclerview:1.2.1'
84    implementation 'androidx.cardview:cardview:1.0.0'
85    implementation 'androidx.percentlayout:percentlayout:1.0.0'
86
87    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
88    implementation 'it.sephiroth.android.library.imagezoom:imagezoom:2.3.0'
89    testImplementation 'org.json:json:20140107'
90    implementation 'com.comscore:android-analytics:6.1.0'
91    implementation 'com.android.support:customtabs:29.0.0'
92    implementation 'androidx.viewpager2:viewpager2:1.0.0'
93    implementation 'com.android.support:customtabs:29.0.0'
94
95    // Kodein Dependency Injection
96    implementation 'org.kodein.di:kodein-di-generic-jvm:6.2.1'
97    implementation 'org.kodein.di:kodein-di-framework-android-x:6.2.1'
98
99    // RETROFIT
100    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
101    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
102    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
103    implementation 'com.google.code.gson:gson:2.8.5'
104    implementation 'com.squareup.retrofit2:converter-scalars:2.1.0' // for test String
105
106
107    // Room components
108    implementation &quot;androidx.room:room-runtime:2.2.5&quot;
109    kapt &quot;androidx.room:room-compiler:2.2.5&quot;
110    implementation &quot;androidx.room:room-ktx:2.2.5&quot;
111    androidTestImplementation &quot;androidx.room:room-testing:2.2.5&quot;
112
113    // Lifecycle components
114    implementation 'android.arch.lifecycle:extensions:1.1.1'
115    implementation 'androidx.paging:paging-runtime:2.1.2'
116
117    // UI
118    implementation 'com.squareup.picasso:picasso:2.71828'
119    implementation 'com.geniusforapp.fancydialog:FancyDialog:0.1.4'
120    implementation 'com.github.bluzwong:swipeback:0.2.0@aar'
121    implementation 'com.airbnb.android:lottie:3.6.0'
122
123    implementation 'com.veinhorn.scrollgalleryview:library:1.2.6'
124    implementation 'com.veinhorn.scrollgalleryview:picasso-loader:1.2.4'
125    implementation 'com.github.rubensousa:bottomsheetbuilder:1.6.1'
126    implementation &quot;com.andkulikov:transitionseverywhere:1.8.1&quot;
127
128
129    // HTTP LOGGING
130    implementation 'com.jakewharton.timber:timber:4.7.1'
131    implementation 'org.jsoup:jsoup:1.13.1'
132    implementation 'androidx.multidex:multidex:2.0.1'
133
134
135    // ADS
136    implementation 'com.android.support:support-annotations:28.0.0'
137    // Required Dependency by Audience Network SDK
138    implementation 'com.google.android.gms:play-services-ads:19.7.0'
139    implementation 'com.google.android.gms:play-services-basement:17.6.0'
140    implementation(&quot;tv.teads.sdk.android:sdk:4.7.2@aar&quot;) {
141        transitive = true
142    }
143    implementation 'com.criteo.publisher:criteo-publisher-sdk:4.0.0'
144    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
145    implementation 'com.google.android.gms:play-services-base:17.6.0'
146
147    implementation ('com.facebook.android:audience-network-sdk:5.5.0'){
148        exclude group: 'com.google.android.gms'
149    }
150
151    implementation 'com.google.firebase:firebase-crashlytics:17.4.0'
152
153    implementation &quot;androidx.core:core-ktx:1.6.0&quot;  // I have update this based on other solution
154    implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1&quot;
155    implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
156
157    // COROUTINES
158    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
159    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
160    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
161
162    // Kotlin + coroutines
163    implementation &quot;androidx.work:work-runtime-ktx:2.5.0&quot;
164
165    implementation 'com.github.mumayank:AirLocation:1.3.1'
166    androidTestImplementation 'androidx.test:rules:1.3.0-beta01'
167
168    implementation 'com.android.installreferrer:installreferrer:2.2'
169
170    //ANIMATION
171    implementation 'com.daimajia.androidanimations:library:2.4@aar'
172    implementation 'com.infideap.drawerbehavior:drawer-behavior:1.0.4'
173    implementation 'com.romandanylyk:pageindicatorview:1.0.3'
174
175    implementation 'org.ocpsoft.prettytime:prettytime:5.0.0.Final'
176
177    //SOCIAL
178    implementation 'com.google.android.gms:play-services-auth:19.0.0'
179
180}
181

I have tried to upgrade version of androidx.core:core-ktx:1.6.0 then sync or invalidate cache/restart. But none of them give me good result. I am sure yesterday my project was alright with same dependency. Someone please help me, if this question unclear let me add more information. Thanks

ANSWER

Answered 2021-Sep-28 at 17:18

I managed to fix this by upgrading compileSdk to 31 and kotlin gradle plugin to 1.5.10

1buildscript {
2    repositories {
3        google()
4        maven { url 'https://plugins.gradle.org/m2/' }
5    }
6
7    dependencies {
8        classpath 'com.google.gms:google-services:4.3.3'
9        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
10    }
11}
12apply plugin: 'com.android.application'
13apply plugin: 'com.google.gms.google-services'
14apply plugin: 'kotlin-android'
15apply plugin: 'kotlin-android-extensions'
16apply plugin: 'kotlin-kapt'
17apply plugin: 'com.google.firebase.crashlytics'
18
19repositories {
20    maven { url 'https://maven.fabric.io/public' }
21    maven { url 'https://maven.google.com' }
22    maven { url  &quot;https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod&quot;}
23    mavenCentral()
24
25}
26
27android {
28    compileSdkVersion 29
29    buildToolsVersion '28.0.3'
30    defaultConfig {
31        applicationId &quot;mobile.apps.my&quot;
32        minSdkVersion 17
33        targetSdkVersion 29
34        multiDexEnabled true
35        versionCode 152
36        versionName &quot;8.1.7&quot;
37        vectorDrawables.useSupportLibrary = true // This line hereP
38        testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
39    }
40
41    compileOptions {
42        sourceCompatibility JavaVersion.VERSION_1_8
43        targetCompatibility JavaVersion.VERSION_1_8
44    }
45
46    dataBinding {
47        enabled = true
48    }
49
50    buildTypes {
51        debug {
52            firebaseCrashlytics {
53                mappingFileUploadEnabled false
54            }
55        }
56
57        release {
58            minifyEnabled true
59            shrinkResources true
60            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
61        }
62    }
63
64    lintOptions {
65        checkReleaseBuilds false
66        abortOnError false
67    }
68}
69
70dependencies {
71
72    implementation fileTree(include: ['*.jar'], dir: 'libs')
73    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0-beta01', {
74        exclude group: 'com.android.support', module: 'support-annotations'
75    })
76    //noinspection GradleCompatible
77    implementation 'androidx.appcompat:appcompat:1.4.0-alpha03'
78    implementation &quot;androidx.appcompat:appcompat-resources:1.4.0-alpha03&quot;
79
80    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
81    implementation 'androidx.preference:preference:1.1.1'
82    implementation 'com.google.android.material:material:1.4.0'
83    implementation 'androidx.recyclerview:recyclerview:1.2.1'
84    implementation 'androidx.cardview:cardview:1.0.0'
85    implementation 'androidx.percentlayout:percentlayout:1.0.0'
86
87    implementation 'com.google.android.gms:play-services-analytics:17.0.0'
88    implementation 'it.sephiroth.android.library.imagezoom:imagezoom:2.3.0'
89    testImplementation 'org.json:json:20140107'
90    implementation 'com.comscore:android-analytics:6.1.0'
91    implementation 'com.android.support:customtabs:29.0.0'
92    implementation 'androidx.viewpager2:viewpager2:1.0.0'
93    implementation 'com.android.support:customtabs:29.0.0'
94
95    // Kodein Dependency Injection
96    implementation 'org.kodein.di:kodein-di-generic-jvm:6.2.1'
97    implementation 'org.kodein.di:kodein-di-framework-android-x:6.2.1'
98
99    // RETROFIT
100    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
101    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
102    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
103    implementation 'com.google.code.gson:gson:2.8.5'
104    implementation 'com.squareup.retrofit2:converter-scalars:2.1.0' // for test String
105
106
107    // Room components
108    implementation &quot;androidx.room:room-runtime:2.2.5&quot;
109    kapt &quot;androidx.room:room-compiler:2.2.5&quot;
110    implementation &quot;androidx.room:room-ktx:2.2.5&quot;
111    androidTestImplementation &quot;androidx.room:room-testing:2.2.5&quot;
112
113    // Lifecycle components
114    implementation 'android.arch.lifecycle:extensions:1.1.1'
115    implementation 'androidx.paging:paging-runtime:2.1.2'
116
117    // UI
118    implementation 'com.squareup.picasso:picasso:2.71828'
119    implementation 'com.geniusforapp.fancydialog:FancyDialog:0.1.4'
120    implementation 'com.github.bluzwong:swipeback:0.2.0@aar'
121    implementation 'com.airbnb.android:lottie:3.6.0'
122
123    implementation 'com.veinhorn.scrollgalleryview:library:1.2.6'
124    implementation 'com.veinhorn.scrollgalleryview:picasso-loader:1.2.4'
125    implementation 'com.github.rubensousa:bottomsheetbuilder:1.6.1'
126    implementation &quot;com.andkulikov:transitionseverywhere:1.8.1&quot;
127
128
129    // HTTP LOGGING
130    implementation 'com.jakewharton.timber:timber:4.7.1'
131    implementation 'org.jsoup:jsoup:1.13.1'
132    implementation 'androidx.multidex:multidex:2.0.1'
133
134
135    // ADS
136    implementation 'com.android.support:support-annotations:28.0.0'
137    // Required Dependency by Audience Network SDK
138    implementation 'com.google.android.gms:play-services-ads:19.7.0'
139    implementation 'com.google.android.gms:play-services-basement:17.6.0'
140    implementation(&quot;tv.teads.sdk.android:sdk:4.7.2@aar&quot;) {
141        transitive = true
142    }
143    implementation 'com.criteo.publisher:criteo-publisher-sdk:4.0.0'
144    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
145    implementation 'com.google.android.gms:play-services-base:17.6.0'
146
147    implementation ('com.facebook.android:audience-network-sdk:5.5.0'){
148        exclude group: 'com.google.android.gms'
149    }
150
151    implementation 'com.google.firebase:firebase-crashlytics:17.4.0'
152
153    implementation &quot;androidx.core:core-ktx:1.6.0&quot;  // I have update this based on other solution
154    implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1&quot;
155    implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
156
157    // COROUTINES
158    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
159    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
160    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
161
162    // Kotlin + coroutines
163    implementation &quot;androidx.work:work-runtime-ktx:2.5.0&quot;
164
165    implementation 'com.github.mumayank:AirLocation:1.3.1'
166    androidTestImplementation 'androidx.test:rules:1.3.0-beta01'
167
168    implementation 'com.android.installreferrer:installreferrer:2.2'
169
170    //ANIMATION
171    implementation 'com.daimajia.androidanimations:library:2.4@aar'
172    implementation 'com.infideap.drawerbehavior:drawer-behavior:1.0.4'
173    implementation 'com.romandanylyk:pageindicatorview:1.0.3'
174
175    implementation 'org.ocpsoft.prettytime:prettytime:5.0.0.Final'
176
177    //SOCIAL
178    implementation 'com.google.android.gms:play-services-auth:19.0.0'
179
180}
181compileSdk = 31
182
183classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10'
184

Source https://stackoverflow.com/questions/69041630

QUESTION

Make ModalBottomSheetLayout always Expanded

Asked 2022-Feb-09 at 10:50

I am using ModalBottomSheetLayout in Jetpack Compose. Whenever it is shown with modalBottomSheetState.show(), it shows HalfExpanded or Expanded depending on the height of its content. This is from the source code:

1val anchors = if (sheetHeight &lt; fullHeight / 2) {
2        mapOf(
3            fullHeight to Hidden,
4            fullHeight - sheetHeight to Expanded
5        )
6    } else {
7        mapOf(
8            fullHeight to Hidden,
9            fullHeight / 2 to HalfExpanded,
10            max(0f, fullHeight - sheetHeight) to Expanded
11        )
12    }
13    Modifier.swipeable(
14        state = sheetState,
15        anchors = anchors,
16        orientation = Orientation.Vertical,
17        enabled = sheetState.currentValue != Hidden,
18        resistance = null
19    )
20

Then show() works like here:

1val anchors = if (sheetHeight &lt; fullHeight / 2) {
2        mapOf(
3            fullHeight to Hidden,
4            fullHeight - sheetHeight to Expanded
5        )
6    } else {
7        mapOf(
8            fullHeight to Hidden,
9            fullHeight / 2 to HalfExpanded,
10            max(0f, fullHeight - sheetHeight) to Expanded
11        )
12    }
13    Modifier.swipeable(
14        state = sheetState,
15        anchors = anchors,
16        orientation = Orientation.Vertical,
17        enabled = sheetState.currentValue != Hidden,
18        resistance = null
19    )
20 internal val isHalfExpandedEnabled: Boolean
21    get() = anchors.values.contains(HalfExpanded)
22
23/**
24 * Show the bottom sheet with animation and suspend until it's shown. If half expand is
25 * enabled, the bottom sheet will be half expanded. Otherwise it will be fully expanded.
26 *
27 * @throws [CancellationException] if the animation is interrupted
28 */
29suspend fun show() {
30    val targetValue =
31        if (isHalfExpandedEnabled) HalfExpanded
32        else Expanded
33    animateTo(targetValue = targetValue)
34}
35

I wonder if we can set it to always Expanded somehow

ANSWER

Answered 2021-Aug-23 at 09:56

You can use:

1val anchors = if (sheetHeight &lt; fullHeight / 2) {
2        mapOf(
3            fullHeight to Hidden,
4            fullHeight - sheetHeight to Expanded
5        )
6    } else {
7        mapOf(
8            fullHeight to Hidden,
9            fullHeight / 2 to HalfExpanded,
10            max(0f, fullHeight - sheetHeight) to Expanded
11        )
12    }
13    Modifier.swipeable(
14        state = sheetState,
15        anchors = anchors,
16        orientation = Orientation.Vertical,
17        enabled = sheetState.currentValue != Hidden,
18        resistance = null
19    )
20 internal val isHalfExpandedEnabled: Boolean
21    get() = anchors.values.contains(HalfExpanded)
22
23/**
24 * Show the bottom sheet with animation and suspend until it's shown. If half expand is
25 * enabled, the bottom sheet will be half expanded. Otherwise it will be fully expanded.
26 *
27 * @throws [CancellationException] if the animation is interrupted
28 */
29suspend fun show() {
30    val targetValue =
31        if (isHalfExpandedEnabled) HalfExpanded
32        else Expanded
33    animateTo(targetValue = targetValue)
34}
35scope.launch { state.animateTo(ModalBottomSheetValue.Expanded) }
36

instead of

1val anchors = if (sheetHeight &lt; fullHeight / 2) {
2        mapOf(
3            fullHeight to Hidden,
4            fullHeight - sheetHeight to Expanded
5        )
6    } else {
7        mapOf(
8            fullHeight to Hidden,
9            fullHeight / 2 to HalfExpanded,
10            max(0f, fullHeight - sheetHeight) to Expanded
11        )
12    }
13    Modifier.swipeable(
14        state = sheetState,
15        anchors = anchors,
16        orientation = Orientation.Vertical,
17        enabled = sheetState.currentValue != Hidden,
18        resistance = null
19    )
20 internal val isHalfExpandedEnabled: Boolean
21    get() = anchors.values.contains(HalfExpanded)
22
23/**
24 * Show the bottom sheet with animation and suspend until it's shown. If half expand is
25 * enabled, the bottom sheet will be half expanded. Otherwise it will be fully expanded.
26 *
27 * @throws [CancellationException] if the animation is interrupted
28 */
29suspend fun show() {
30    val targetValue =
31        if (isHalfExpandedEnabled) HalfExpanded
32        else Expanded
33    animateTo(targetValue = targetValue)
34}
35scope.launch { state.animateTo(ModalBottomSheetValue.Expanded) }
36scope.launch { state.show() }
37

Source https://stackoverflow.com/questions/68890357

QUESTION

Project update recommended: Android Gradle Plugin can be upgraded. Error message: Can not find AGP version in build files

Asked 2022-Feb-06 at 03:17

After a recommendation in Android Studio to upgrade Android Gradle Plugin from 7.0.0 to 7.0.2 the Upgrade Assistant notifies that Cannot find AGP version in build files, and therefore I am not able to do the upgrade.

What shall I do?

Thanks

Code at build.gradle (project)

1buildscript {
2    repositories {
3        google()
4    }
5    dependencies {
6        classpath Libs.androidGradlePlugin
7        classpath Libs.Kotlin.gradlePlugin
8        classpath Libs.Hilt.gradlePlugin
9    }
10}
11
12plugins {
13    id 'com.diffplug.spotless' version '5.12.4'
14}
15
16subprojects {
17    repositories {
18        google()
19        mavenCentral()
20
21        if (!Libs.AndroidX.Compose.snapshot.isEmpty()) {
22            maven { url Urls.composeSnapshotRepo }
23        }
24
25        if (Libs.Accompanist.version.endsWith('SNAPSHOT')) {
26            maven { url Urls.mavenCentralSnapshotRepo }
27        }
28    }
29
30    apply plugin: 'com.diffplug.spotless'
31    spotless {
32        kotlin {
33            target '**/*.kt'
34            targetExclude(&quot;$buildDir/**/*.kt&quot;)
35            targetExclude('bin/**/*.kt')
36            ktlint(Versions.ktLint)
37            licenseHeaderFile rootProject.file('spotless/copyright.kt')
38        }
39    }
40
41    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
42        kotlinOptions {
43            jvmTarget = &quot;1.8&quot;
44
45            // Use experimental APIs
46            freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
47        }
48    }
49    // androidx.test and hilt are forcing JUnit, 4.12. This forces them to use 4.13
50    configurations.configureEach {
51        resolutionStrategy {
52            force Libs.JUnit.junit
53        }
54    }
55}
56
57

Code at build.gradle (module)

1buildscript {
2    repositories {
3        google()
4    }
5    dependencies {
6        classpath Libs.androidGradlePlugin
7        classpath Libs.Kotlin.gradlePlugin
8        classpath Libs.Hilt.gradlePlugin
9    }
10}
11
12plugins {
13    id 'com.diffplug.spotless' version '5.12.4'
14}
15
16subprojects {
17    repositories {
18        google()
19        mavenCentral()
20
21        if (!Libs.AndroidX.Compose.snapshot.isEmpty()) {
22            maven { url Urls.composeSnapshotRepo }
23        }
24
25        if (Libs.Accompanist.version.endsWith('SNAPSHOT')) {
26            maven { url Urls.mavenCentralSnapshotRepo }
27        }
28    }
29
30    apply plugin: 'com.diffplug.spotless'
31    spotless {
32        kotlin {
33            target '**/*.kt'
34            targetExclude(&quot;$buildDir/**/*.kt&quot;)
35            targetExclude('bin/**/*.kt')
36            ktlint(Versions.ktLint)
37            licenseHeaderFile rootProject.file('spotless/copyright.kt')
38        }
39    }
40
41    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
42        kotlinOptions {
43            jvmTarget = &quot;1.8&quot;
44
45            // Use experimental APIs
46            freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
47        }
48    }
49    // androidx.test and hilt are forcing JUnit, 4.12. This forces them to use 4.13
50    configurations.configureEach {
51        resolutionStrategy {
52            force Libs.JUnit.junit
53        }
54    }
55}
56
57plugins {
58    id 'com.android.application'
59    id 'kotlin-android'
60    id 'kotlin-kapt'
61    id 'dagger.hilt.android.plugin'
62}
63
64// Reads the Google maps key that is used in the AndroidManifest
65Properties properties = new Properties()
66if (rootProject.file(&quot;local.properties&quot;).exists()) {
67    properties.load(rootProject.file(&quot;local.properties&quot;).newDataInputStream())
68}
69
70android {
71    compileSdkVersion 31
72    defaultConfig {
73        applicationId &quot;androidx.compose.samples.crane&quot;
74        minSdkVersion 21
75        targetSdkVersion 31
76        versionCode 1
77        versionName &quot;1.0&quot;
78        vectorDrawables.useSupportLibrary = true
79        testInstrumentationRunner &quot;androidx.compose.samples.crane.CustomTestRunner&quot;
80
81        manifestPlaceholders = [ googleMapsKey : properties.getProperty(&quot;google.maps.key&quot;, &quot;&quot;) ]
82    }
83
84    signingConfigs {
85        // We use a bundled debug keystore, to allow debug builds from CI to be upgradable
86        // Cert fingerprint = 
87        debug {
88            storeFile rootProject.file('debug.keystore')
89            storePassword 'xxxxxxxxxx'
90            keyAlias 'xxxxxxxxxxx'
91            keyPassword 'xxxxxxxxxx'
92        }
93    }
94
95    buildTypes {
96        debug {
97            signingConfig signingConfigs.debug
98        }
99
100        release {
101            minifyEnabled true
102            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
103        }
104    }
105
106    compileOptions {
107        sourceCompatibility JavaVersion.VERSION_1_8
108        targetCompatibility JavaVersion.VERSION_1_8
109    }
110
111    kotlinOptions {
112        jvmTarget = &quot;1.8&quot;
113    }
114
115    buildFeatures {
116         compose true
117
118        // Disable unused AGP features
119        buildConfig false
120        aidl false
121        renderScript false
122        resValues false
123        shaders false
124    }
125
126    composeOptions {
127        kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
128    }
129
130    packagingOptions {
131        // Multiple dependency bring these files in. Exclude them to enable
132        // our test APK to build (has no effect on our AARs)
133        excludes += &quot;/META-INF/AL2.0&quot;
134        excludes += &quot;/META-INF/LGPL2.1&quot;
135    }
136}
137
138dependencies {
139    implementation Libs.Kotlin.stdlib
140    implementation Libs.Kotlin.Coroutines.android
141    implementation Libs.GoogleMaps.maps
142    implementation Libs.GoogleMaps.mapsKtx
143    constraints {
144        // Volley is a transitive dependency of maps
145        implementation(Libs.Volley.volley) {
146            because(&quot;Only volley 1.2.0 or newer are available on maven.google.com&quot;)
147        }
148    }
149
150    implementation Libs.Accompanist.insets
151    implementation Libs.AndroidX.Activity.activityCompose
152    implementation Libs.AndroidX.appcompat
153    implementation Libs.AndroidX.Compose.runtime
154    implementation Libs.AndroidX.Compose.foundation
155    implementation Libs.AndroidX.Compose.material
156    implementation Libs.AndroidX.Compose.layout
157    implementation Libs.AndroidX.Compose.animation
158    implementation Libs.AndroidX.Compose.tooling
159    implementation Libs.AndroidX.Lifecycle.viewModelCompose
160    implementation Libs.AndroidX.Lifecycle.viewModelKtx
161    implementation Libs.Coil.compose
162    implementation Libs.Hilt.android
163    kapt Libs.Hilt.compiler
164
165    androidTestImplementation Libs.JUnit.junit
166    androidTestImplementation Libs.AndroidX.Test.runner
167    androidTestImplementation Libs.AndroidX.Test.espressoCore
168    androidTestImplementation Libs.AndroidX.Test.rules
169    androidTestImplementation Libs.AndroidX.Test.Ext.junit
170    androidTestImplementation Libs.Kotlin.Coroutines.test
171    androidTestImplementation Libs.AndroidX.Compose.uiTest
172    androidTestImplementation Libs.Hilt.android
173    androidTestImplementation Libs.Hilt.testing
174    kaptAndroidTest Libs.Hilt.compiler
175}
176

Code at build.gradle.kts

1buildscript {
2    repositories {
3        google()
4    }
5    dependencies {
6        classpath Libs.androidGradlePlugin
7        classpath Libs.Kotlin.gradlePlugin
8        classpath Libs.Hilt.gradlePlugin
9    }
10}
11
12plugins {
13    id 'com.diffplug.spotless' version '5.12.4'
14}
15
16subprojects {
17    repositories {
18        google()
19        mavenCentral()
20
21        if (!Libs.AndroidX.Compose.snapshot.isEmpty()) {
22            maven { url Urls.composeSnapshotRepo }
23        }
24
25        if (Libs.Accompanist.version.endsWith('SNAPSHOT')) {
26            maven { url Urls.mavenCentralSnapshotRepo }
27        }
28    }
29
30    apply plugin: 'com.diffplug.spotless'
31    spotless {
32        kotlin {
33            target '**/*.kt'
34            targetExclude(&quot;$buildDir/**/*.kt&quot;)
35            targetExclude('bin/**/*.kt')
36            ktlint(Versions.ktLint)
37            licenseHeaderFile rootProject.file('spotless/copyright.kt')
38        }
39    }
40
41    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
42        kotlinOptions {
43            jvmTarget = &quot;1.8&quot;
44
45            // Use experimental APIs
46            freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
47        }
48    }
49    // androidx.test and hilt are forcing JUnit, 4.12. This forces them to use 4.13
50    configurations.configureEach {
51        resolutionStrategy {
52            force Libs.JUnit.junit
53        }
54    }
55}
56
57plugins {
58    id 'com.android.application'
59    id 'kotlin-android'
60    id 'kotlin-kapt'
61    id 'dagger.hilt.android.plugin'
62}
63
64// Reads the Google maps key that is used in the AndroidManifest
65Properties properties = new Properties()
66if (rootProject.file(&quot;local.properties&quot;).exists()) {
67    properties.load(rootProject.file(&quot;local.properties&quot;).newDataInputStream())
68}
69
70android {
71    compileSdkVersion 31
72    defaultConfig {
73        applicationId &quot;androidx.compose.samples.crane&quot;
74        minSdkVersion 21
75        targetSdkVersion 31
76        versionCode 1
77        versionName &quot;1.0&quot;
78        vectorDrawables.useSupportLibrary = true
79        testInstrumentationRunner &quot;androidx.compose.samples.crane.CustomTestRunner&quot;
80
81        manifestPlaceholders = [ googleMapsKey : properties.getProperty(&quot;google.maps.key&quot;, &quot;&quot;) ]
82    }
83
84    signingConfigs {
85        // We use a bundled debug keystore, to allow debug builds from CI to be upgradable
86        // Cert fingerprint = 
87        debug {
88            storeFile rootProject.file('debug.keystore')
89            storePassword 'xxxxxxxxxx'
90            keyAlias 'xxxxxxxxxxx'
91            keyPassword 'xxxxxxxxxx'
92        }
93    }
94
95    buildTypes {
96        debug {
97            signingConfig signingConfigs.debug
98        }
99
100        release {
101            minifyEnabled true
102            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
103        }
104    }
105
106    compileOptions {
107        sourceCompatibility JavaVersion.VERSION_1_8
108        targetCompatibility JavaVersion.VERSION_1_8
109    }
110
111    kotlinOptions {
112        jvmTarget = &quot;1.8&quot;
113    }
114
115    buildFeatures {
116         compose true
117
118        // Disable unused AGP features
119        buildConfig false
120        aidl false
121        renderScript false
122        resValues false
123        shaders false
124    }
125
126    composeOptions {
127        kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
128    }
129
130    packagingOptions {
131        // Multiple dependency bring these files in. Exclude them to enable
132        // our test APK to build (has no effect on our AARs)
133        excludes += &quot;/META-INF/AL2.0&quot;
134        excludes += &quot;/META-INF/LGPL2.1&quot;
135    }
136}
137
138dependencies {
139    implementation Libs.Kotlin.stdlib
140    implementation Libs.Kotlin.Coroutines.android
141    implementation Libs.GoogleMaps.maps
142    implementation Libs.GoogleMaps.mapsKtx
143    constraints {
144        // Volley is a transitive dependency of maps
145        implementation(Libs.Volley.volley) {
146            because(&quot;Only volley 1.2.0 or newer are available on maven.google.com&quot;)
147        }
148    }
149
150    implementation Libs.Accompanist.insets
151    implementation Libs.AndroidX.Activity.activityCompose
152    implementation Libs.AndroidX.appcompat
153    implementation Libs.AndroidX.Compose.runtime
154    implementation Libs.AndroidX.Compose.foundation
155    implementation Libs.AndroidX.Compose.material
156    implementation Libs.AndroidX.Compose.layout
157    implementation Libs.AndroidX.Compose.animation
158    implementation Libs.AndroidX.Compose.tooling
159    implementation Libs.AndroidX.Lifecycle.viewModelCompose
160    implementation Libs.AndroidX.Lifecycle.viewModelKtx
161    implementation Libs.Coil.compose
162    implementation Libs.Hilt.android
163    kapt Libs.Hilt.compiler
164
165    androidTestImplementation Libs.JUnit.junit
166    androidTestImplementation Libs.AndroidX.Test.runner
167    androidTestImplementation Libs.AndroidX.Test.espressoCore
168    androidTestImplementation Libs.AndroidX.Test.rules
169    androidTestImplementation Libs.AndroidX.Test.Ext.junit
170    androidTestImplementation Libs.Kotlin.Coroutines.test
171    androidTestImplementation Libs.AndroidX.Compose.uiTest
172    androidTestImplementation Libs.Hilt.android
173    androidTestImplementation Libs.Hilt.testing
174    kaptAndroidTest Libs.Hilt.compiler
175}
176repositories {
177    jcenter()
178}
179
180plugins {
181    `kotlin-dsl`
182}
183

ANSWER

Answered 2022-Feb-06 at 03:17

I don't know if it is critical for your problem but modifying this

1buildscript {
2    repositories {
3        google()
4    }
5    dependencies {
6        classpath Libs.androidGradlePlugin
7        classpath Libs.Kotlin.gradlePlugin
8        classpath Libs.Hilt.gradlePlugin
9    }
10}
11
12plugins {
13    id 'com.diffplug.spotless' version '5.12.4'
14}
15
16subprojects {
17    repositories {
18        google()
19        mavenCentral()
20
21        if (!Libs.AndroidX.Compose.snapshot.isEmpty()) {
22            maven { url Urls.composeSnapshotRepo }
23        }
24
25        if (Libs.Accompanist.version.endsWith('SNAPSHOT')) {
26            maven { url Urls.mavenCentralSnapshotRepo }
27        }
28    }
29
30    apply plugin: 'com.diffplug.spotless'
31    spotless {
32        kotlin {
33            target '**/*.kt'
34            targetExclude(&quot;$buildDir/**/*.kt&quot;)
35            targetExclude('bin/**/*.kt')
36            ktlint(Versions.ktLint)
37            licenseHeaderFile rootProject.file('spotless/copyright.kt')
38        }
39    }
40
41    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
42        kotlinOptions {
43            jvmTarget = &quot;1.8&quot;
44
45            // Use experimental APIs
46            freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
47        }
48    }
49    // androidx.test and hilt are forcing JUnit, 4.12. This forces them to use 4.13
50    configurations.configureEach {
51        resolutionStrategy {
52            force Libs.JUnit.junit
53        }
54    }
55}
56
57plugins {
58    id 'com.android.application'
59    id 'kotlin-android'
60    id 'kotlin-kapt'
61    id 'dagger.hilt.android.plugin'
62}
63
64// Reads the Google maps key that is used in the AndroidManifest
65Properties properties = new Properties()
66if (rootProject.file(&quot;local.properties&quot;).exists()) {
67    properties.load(rootProject.file(&quot;local.properties&quot;).newDataInputStream())
68}
69
70android {
71    compileSdkVersion 31
72    defaultConfig {
73        applicationId &quot;androidx.compose.samples.crane&quot;
74        minSdkVersion 21
75        targetSdkVersion 31
76        versionCode 1
77        versionName &quot;1.0&quot;
78        vectorDrawables.useSupportLibrary = true
79        testInstrumentationRunner &quot;androidx.compose.samples.crane.CustomTestRunner&quot;
80
81        manifestPlaceholders = [ googleMapsKey : properties.getProperty(&quot;google.maps.key&quot;, &quot;&quot;) ]
82    }
83
84    signingConfigs {
85        // We use a bundled debug keystore, to allow debug builds from CI to be upgradable
86        // Cert fingerprint = 
87        debug {
88            storeFile rootProject.file('debug.keystore')
89            storePassword 'xxxxxxxxxx'
90            keyAlias 'xxxxxxxxxxx'
91            keyPassword 'xxxxxxxxxx'
92        }
93    }
94
95    buildTypes {
96        debug {
97            signingConfig signingConfigs.debug
98        }
99
100        release {
101            minifyEnabled true
102            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
103        }
104    }
105
106    compileOptions {
107        sourceCompatibility JavaVersion.VERSION_1_8
108        targetCompatibility JavaVersion.VERSION_1_8
109    }
110
111    kotlinOptions {
112        jvmTarget = &quot;1.8&quot;
113    }
114
115    buildFeatures {
116         compose true
117
118        // Disable unused AGP features
119        buildConfig false
120        aidl false
121        renderScript false
122        resValues false
123        shaders false
124    }
125
126    composeOptions {
127        kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
128    }
129
130    packagingOptions {
131        // Multiple dependency bring these files in. Exclude them to enable
132        // our test APK to build (has no effect on our AARs)
133        excludes += &quot;/META-INF/AL2.0&quot;
134        excludes += &quot;/META-INF/LGPL2.1&quot;
135    }
136}
137
138dependencies {
139    implementation Libs.Kotlin.stdlib
140    implementation Libs.Kotlin.Coroutines.android
141    implementation Libs.GoogleMaps.maps
142    implementation Libs.GoogleMaps.mapsKtx
143    constraints {
144        // Volley is a transitive dependency of maps
145        implementation(Libs.Volley.volley) {
146            because(&quot;Only volley 1.2.0 or newer are available on maven.google.com&quot;)
147        }
148    }
149
150    implementation Libs.Accompanist.insets
151    implementation Libs.AndroidX.Activity.activityCompose
152    implementation Libs.AndroidX.appcompat
153    implementation Libs.AndroidX.Compose.runtime
154    implementation Libs.AndroidX.Compose.foundation
155    implementation Libs.AndroidX.Compose.material
156    implementation Libs.AndroidX.Compose.layout
157    implementation Libs.AndroidX.Compose.animation
158    implementation Libs.AndroidX.Compose.tooling
159    implementation Libs.AndroidX.Lifecycle.viewModelCompose
160    implementation Libs.AndroidX.Lifecycle.viewModelKtx
161    implementation Libs.Coil.compose
162    implementation Libs.Hilt.android
163    kapt Libs.Hilt.compiler
164
165    androidTestImplementation Libs.JUnit.junit
166    androidTestImplementation Libs.AndroidX.Test.runner
167    androidTestImplementation Libs.AndroidX.Test.espressoCore
168    androidTestImplementation Libs.AndroidX.Test.rules
169    androidTestImplementation Libs.AndroidX.Test.Ext.junit
170    androidTestImplementation Libs.Kotlin.Coroutines.test
171    androidTestImplementation Libs.AndroidX.Compose.uiTest
172    androidTestImplementation Libs.Hilt.android
173    androidTestImplementation Libs.Hilt.testing
174    kaptAndroidTest Libs.Hilt.compiler
175}
176repositories {
177    jcenter()
178}
179
180plugins {
181    `kotlin-dsl`
182}
183repositories {
184    jcenter()
185}
186

to

1buildscript {
2    repositories {
3        google()
4    }
5    dependencies {
6        classpath Libs.androidGradlePlugin
7        classpath Libs.Kotlin.gradlePlugin
8        classpath Libs.Hilt.gradlePlugin
9    }
10}
11
12plugins {
13    id 'com.diffplug.spotless' version '5.12.4'
14}
15
16subprojects {
17    repositories {
18        google()
19        mavenCentral()
20
21        if (!Libs.AndroidX.Compose.snapshot.isEmpty()) {
22            maven { url Urls.composeSnapshotRepo }
23        }
24
25        if (Libs.Accompanist.version.endsWith('SNAPSHOT')) {
26            maven { url Urls.mavenCentralSnapshotRepo }
27        }
28    }
29
30    apply plugin: 'com.diffplug.spotless'
31    spotless {
32        kotlin {
33            target '**/*.kt'
34            targetExclude(&quot;$buildDir/**/*.kt&quot;)
35            targetExclude('bin/**/*.kt')
36            ktlint(Versions.ktLint)
37            licenseHeaderFile rootProject.file('spotless/copyright.kt')
38        }
39    }
40
41    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
42        kotlinOptions {
43            jvmTarget = &quot;1.8&quot;
44
45            // Use experimental APIs
46            freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
47        }
48    }
49    // androidx.test and hilt are forcing JUnit, 4.12. This forces them to use 4.13
50    configurations.configureEach {
51        resolutionStrategy {
52            force Libs.JUnit.junit
53        }
54    }
55}
56
57plugins {
58    id 'com.android.application'
59    id 'kotlin-android'
60    id 'kotlin-kapt'
61    id 'dagger.hilt.android.plugin'
62}
63
64// Reads the Google maps key that is used in the AndroidManifest
65Properties properties = new Properties()
66if (rootProject.file(&quot;local.properties&quot;).exists()) {
67    properties.load(rootProject.file(&quot;local.properties&quot;).newDataInputStream())
68}
69
70android {
71    compileSdkVersion 31
72    defaultConfig {
73        applicationId &quot;androidx.compose.samples.crane&quot;
74        minSdkVersion 21
75        targetSdkVersion 31
76        versionCode 1
77        versionName &quot;1.0&quot;
78        vectorDrawables.useSupportLibrary = true
79        testInstrumentationRunner &quot;androidx.compose.samples.crane.CustomTestRunner&quot;
80
81        manifestPlaceholders = [ googleMapsKey : properties.getProperty(&quot;google.maps.key&quot;, &quot;&quot;) ]
82    }
83
84    signingConfigs {
85        // We use a bundled debug keystore, to allow debug builds from CI to be upgradable
86        // Cert fingerprint = 
87        debug {
88            storeFile rootProject.file('debug.keystore')
89            storePassword 'xxxxxxxxxx'
90            keyAlias 'xxxxxxxxxxx'
91            keyPassword 'xxxxxxxxxx'
92        }
93    }
94
95    buildTypes {
96        debug {
97            signingConfig signingConfigs.debug
98        }
99
100        release {
101            minifyEnabled true
102            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
103        }
104    }
105
106    compileOptions {
107        sourceCompatibility JavaVersion.VERSION_1_8
108        targetCompatibility JavaVersion.VERSION_1_8
109    }
110
111    kotlinOptions {
112        jvmTarget = &quot;1.8&quot;
113    }
114
115    buildFeatures {
116         compose true
117
118        // Disable unused AGP features
119        buildConfig false
120        aidl false
121        renderScript false
122        resValues false
123        shaders false
124    }
125
126    composeOptions {
127        kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
128    }
129
130    packagingOptions {
131        // Multiple dependency bring these files in. Exclude them to enable
132        // our test APK to build (has no effect on our AARs)
133        excludes += &quot;/META-INF/AL2.0&quot;
134        excludes += &quot;/META-INF/LGPL2.1&quot;
135    }
136}
137
138dependencies {
139    implementation Libs.Kotlin.stdlib
140    implementation Libs.Kotlin.Coroutines.android
141    implementation Libs.GoogleMaps.maps
142    implementation Libs.GoogleMaps.mapsKtx
143    constraints {
144        // Volley is a transitive dependency of maps
145        implementation(Libs.Volley.volley) {
146            because(&quot;Only volley 1.2.0 or newer are available on maven.google.com&quot;)
147        }
148    }
149
150    implementation Libs.Accompanist.insets
151    implementation Libs.AndroidX.Activity.activityCompose
152    implementation Libs.AndroidX.appcompat
153    implementation Libs.AndroidX.Compose.runtime
154    implementation Libs.AndroidX.Compose.foundation
155    implementation Libs.AndroidX.Compose.material
156    implementation Libs.AndroidX.Compose.layout
157    implementation Libs.AndroidX.Compose.animation
158    implementation Libs.AndroidX.Compose.tooling
159    implementation Libs.AndroidX.Lifecycle.viewModelCompose
160    implementation Libs.AndroidX.Lifecycle.viewModelKtx
161    implementation Libs.Coil.compose
162    implementation Libs.Hilt.android
163    kapt Libs.Hilt.compiler
164
165    androidTestImplementation Libs.JUnit.junit
166    androidTestImplementation Libs.AndroidX.Test.runner
167    androidTestImplementation Libs.AndroidX.Test.espressoCore
168    androidTestImplementation Libs.AndroidX.Test.rules
169    androidTestImplementation Libs.AndroidX.Test.Ext.junit
170    androidTestImplementation Libs.Kotlin.Coroutines.test
171    androidTestImplementation Libs.AndroidX.Compose.uiTest
172    androidTestImplementation Libs.Hilt.android
173    androidTestImplementation Libs.Hilt.testing
174    kaptAndroidTest Libs.Hilt.compiler
175}
176repositories {
177    jcenter()
178}
179
180plugins {
181    `kotlin-dsl`
182}
183repositories {
184    jcenter()
185}
186repositories {
187    mavenCentral()
188}
189

should be needed. Because jcenter() is obsolete.

Source https://stackoverflow.com/questions/69307474

QUESTION

Angular TSLint - Cannot find builder &quot;@angular-devkit/build-angular:tslint&quot;

Asked 2022-Jan-04 at 13:18

When I try to run command ng lint --fix cli throws this error:

1An unhandled exception occurred: Cannot find builder &quot;@angular-devkit/build-angular:tslint&quot;.
2See &quot;C:\Users\MOE89A~1.ZAR\AppData\Local\Temp\ng-Ijc3an\angular-errors.log&quot; for further details.
3

My lint confing in angular.json:

1An unhandled exception occurred: Cannot find builder &quot;@angular-devkit/build-angular:tslint&quot;.
2See &quot;C:\Users\MOE89A~1.ZAR\AppData\Local\Temp\ng-Ijc3an\angular-errors.log&quot; for further details.
3&quot;lint&quot;: {
4  &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
5  &quot;options&quot;: {
6    &quot;tsConfig&quot;: [
7      &quot;projects/wepod-app/tsconfig.app.json&quot;,
8      &quot;projects/wepod-app/tsconfig.spec.json&quot;,
9      &quot;projects/wepod-app/e2e/tsconfig.json&quot;
10    ],
11    &quot;exclude&quot;: [
12      &quot;**/node_modules/**&quot;
13    ]
14  }
15},
16

My package.json:

1An unhandled exception occurred: Cannot find builder &quot;@angular-devkit/build-angular:tslint&quot;.
2See &quot;C:\Users\MOE89A~1.ZAR\AppData\Local\Temp\ng-Ijc3an\angular-errors.log&quot; for further details.
3&quot;lint&quot;: {
4  &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
5  &quot;options&quot;: {
6    &quot;tsConfig&quot;: [
7      &quot;projects/wepod-app/tsconfig.app.json&quot;,
8      &quot;projects/wepod-app/tsconfig.spec.json&quot;,
9      &quot;projects/wepod-app/e2e/tsconfig.json&quot;
10    ],
11    &quot;exclude&quot;: [
12      &quot;**/node_modules/**&quot;
13    ]
14  }
15},
16{
17  &quot;name&quot;: &quot;wepod-clients&quot;,
18  &quot;version&quot;: &quot;3.2.3&quot;,
19  &quot;scripts&quot;: {
20    &quot;ng&quot;: &quot;ng&quot;,
21    &quot;start&quot;: &quot;node patch.js &amp;&amp; ng serve&quot;,
22    &quot;build&quot;: &quot;node patch.js &amp;&amp; node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng run wepod-app:app-shell:production &amp;&amp; ng run wepod-app:auth-standalone:production&quot;,
23    &quot;server&quot;: &quot;npm run build &amp;&amp; http-server -p 9090 -c-1 dist&quot;,
24    &quot;test&quot;: &quot;ng test&quot;,
25    &quot;lint&quot;: &quot;ng lint --fix&quot;,
26    &quot;e2e&quot;: &quot;ng e2e&quot;,
27    &quot;postinstall&quot;: &quot;node patch.js &amp;&amp; ngcc&quot;,
28    &quot;postbuild&quot;: &quot;node post-build.js&quot;,
29    &quot;prepare&quot;: &quot;husky install&quot;,
30    &quot;build-latest&quot;: &quot;git pull origin production &amp;&amp; npm run build&quot;
31  },
32  &quot;private&quot;: true,
33  &quot;dependencies&quot;: {
34    &quot;@angular/animations&quot;: &quot;^13.0.0&quot;,
35    &quot;@angular/cdk&quot;: &quot;^13.0.0&quot;,
36    &quot;@angular/cli&quot;: &quot;^13.0.1&quot;,
37    &quot;@angular/common&quot;: &quot;^13.0.0&quot;,
38    &quot;@angular/compiler&quot;: &quot;^13.0.0&quot;,
39    &quot;@angular/core&quot;: &quot;^13.0.0&quot;,
40    &quot;@angular/forms&quot;: &quot;^13.0.0&quot;,
41    &quot;@angular/localize&quot;: &quot;^13.0.0&quot;,
42    &quot;@angular/platform-browser&quot;: &quot;^13.0.0&quot;,
43    &quot;@angular/platform-browser-dynamic&quot;: &quot;^13.0.0&quot;,
44    &quot;@angular/platform-server&quot;: &quot;^13.0.0&quot;,
45    &quot;@angular/router&quot;: &quot;^13.0.0&quot;,
46    &quot;@angular/service-worker&quot;: &quot;^13.0.0&quot;,
47    &quot;@types/video.js&quot;: &quot;^7.3.27&quot;,
48    &quot;animate.css&quot;: &quot;^4.1.1&quot;,
49    &quot;assert&quot;: &quot;^2.0.0&quot;,
50    &quot;bowser&quot;: &quot;^2.11.0&quot;,
51    &quot;buffer&quot;: &quot;^6.0.3&quot;,
52    &quot;bundle-loader&quot;: &quot;^0.5.6&quot;,
53    &quot;compare-version&quot;: &quot;^0.1.2&quot;,
54    &quot;constants-browserify&quot;: &quot;^1.0.0&quot;,
55    &quot;crypto-browserify&quot;: &quot;^3.12.0&quot;,
56    &quot;crypto-js&quot;: &quot;^4.1.1&quot;,
57    &quot;d3&quot;: &quot;^6.5.0&quot;,
58    &quot;hammerjs&quot;: &quot;^2.0.8&quot;,
59    &quot;https-browserify&quot;: &quot;^1.0.0&quot;,
60    &quot;jalali-moment&quot;: &quot;^3.3.10&quot;,
61    &quot;lottie-web&quot;: &quot;^5.7.13&quot;,
62    &quot;lzutf8&quot;: &quot;^0.6.0&quot;,
63    &quot;net&quot;: &quot;^1.0.2&quot;,
64    &quot;ng-gallery&quot;: &quot;^5.1.1&quot;,
65    &quot;ng2-jalali-date-picker&quot;: &quot;^2.4.2&quot;,
66    &quot;ngx-device-detector&quot;: &quot;^1.5.2&quot;,
67    &quot;ngx-doughnut-chart&quot;: &quot;0.0.4&quot;,
68    &quot;ngx-infinite-scroll&quot;: &quot;^8.0.2&quot;,
69    &quot;ngx-lottie&quot;: &quot;^7.0.4&quot;,
70    &quot;ngx-owl-carousel-o&quot;: &quot;^3.1.1&quot;,
71    &quot;ngx-skeleton-loader&quot;: &quot;^2.10.1&quot;,
72    &quot;ngx-toastr&quot;: &quot;^12.1.0&quot;,
73    &quot;os-browserify&quot;: &quot;^0.3.0&quot;,
74    &quot;podchat-browser&quot;: &quot;^10.14.13&quot;,
75    &quot;rxjs&quot;: &quot;^6.6.7&quot;,
76    &quot;stream-browserify&quot;: &quot;^3.0.0&quot;,
77    &quot;stream-http&quot;: &quot;^3.2.0&quot;,
78    &quot;tls&quot;: &quot;0.0.1&quot;,
79    &quot;tslib&quot;: &quot;^2.0.0&quot;,
80    &quot;uuid&quot;: &quot;^8.3.2&quot;,
81    &quot;video.js&quot;: &quot;^7.15.4&quot;,
82    &quot;videojs-record&quot;: &quot;^4.5.0&quot;,
83    &quot;zone.js&quot;: &quot;~0.11.4&quot;
84  },
85  &quot;devDependencies&quot;: {
86    &quot;@angular-devkit/build-angular&quot;: &quot;^13.0.1&quot;,
87    &quot;@angular-devkit/core&quot;: &quot;^13.0.1&quot;,
88    &quot;@angular/compiler-cli&quot;: &quot;^13.0.0&quot;,
89    &quot;@angular/language-service&quot;: &quot;^13.0.0&quot;,
90    &quot;@egjs/hammerjs&quot;: &quot;^2.0.17&quot;,
91    &quot;@types/hammerjs&quot;: &quot;^2.0.40&quot;,
92    &quot;@types/jasmine&quot;: &quot;~3.6.0&quot;,
93    &quot;@types/jasminewd2&quot;: &quot;^2.0.10&quot;,
94    &quot;@types/node&quot;: &quot;^12.20.36&quot;,
95    &quot;codelyzer&quot;: &quot;^6.0.0&quot;,
96    &quot;colors&quot;: &quot;^1.4.0&quot;,
97    &quot;git-tag-version&quot;: &quot;^1.3.1&quot;,
98    &quot;gulp&quot;: &quot;^4.0.2&quot;,
99    &quot;gulp-gzip&quot;: &quot;^1.4.2&quot;,
100    &quot;http-server&quot;: &quot;^14.0.0&quot;,
101    &quot;husky&quot;: &quot;^7.0.4&quot;,
102    &quot;jasmine-core&quot;: &quot;~3.6.0&quot;,
103    &quot;jasmine-spec-reporter&quot;: &quot;~5.0.0&quot;,
104    &quot;karma&quot;: &quot;^6.3.7&quot;,
105    &quot;karma-chrome-launcher&quot;: &quot;~3.1.0&quot;,
106    &quot;karma-coverage-istanbul-reporter&quot;: &quot;^2.1.0&quot;,
107    &quot;karma-jasmine&quot;: &quot;~4.0.0&quot;,
108    &quot;karma-jasmine-html-reporter&quot;: &quot;^1.5.0&quot;,
109    &quot;protractor&quot;: &quot;^7.0.0&quot;,
110    &quot;ts-node&quot;: &quot;^8.10.2&quot;,
111    &quot;tslint&quot;: &quot;^6.1.3&quot;,
112    &quot;typescript&quot;: &quot;4.4.4&quot;,
113    &quot;zip-dir&quot;: &quot;^2.0.0&quot;
114  },
115  &quot;browser&quot;: {
116    &quot;fs&quot;: false,
117    &quot;path&quot;: false,
118    &quot;os&quot;: false
119  }
120}
121

ANSWER

Answered 2021-Nov-28 at 10:34

From v13 angular doesn't use tslint anymore due to deprecation.

Run ng add @angular-eslint/schematics to add eslint to your application.

It will use tslint-to-eslint-config to migrate you to eslint automatically.

It will generate a .eslintrc.json file and migrate tslint.json to it.

Nothing else is needed to be done.

Source https://stackoverflow.com/questions/70141707

QUESTION

SVG stop running chained animation (&lt;animate&gt; tag)

Asked 2021-Dec-26 at 09:01

I have an animated SVG where each <path> starts after its previous <path>. The first <path> starts on click or 0s.
I have a problem with stopping the animation (without JS, only in XML). I press click, the animation starts. Before the entire animation ends I press click and trigger a new animation. However the previous animation continues to run and it messes up all <path>s starting from 2.
I have tried different options (begin with time offsets; begin with id.end), but I haven't found a solution. Maybe someone who is more experiences with SVG than me could help me?

Here is my SVG:

1&lt;svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109" id="3005"&gt;
2&lt;g fill="none" stroke="#666" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"&gt;
3    &lt;g&gt;
4        &lt;path d="M50.75,19.5c0.1,1.3,0.37,3.74-0.19,5.21C43.57,43,32.73,60.29,14.5,75.04" /&gt;
5        &lt;path d="M45,44.35c1.05,0,3.62,0.35,6.26,0.1c9.18-0.85,25.21-3.31,29.06-3.67c4.26-0.4,6.46,4.28,4.68,6.25C78.32,54.46,67.5,67,57.81,79.22" /&gt;
6        &lt;path d="M42.52,68.33c10.16,5.01,26.25,20.59,28.79,28.38" /&gt;
7    &lt;/g&gt;
8&lt;/g&gt;
9&lt;g fill="none" stroke="#000" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"&gt;
10    &lt;g&gt;
11        &lt;path d="M50.75,19.5c0.1,1.3,0.37,3.74-0.19,5.21C43.57,43,32.73,60.29,14.5,75.04" stroke-dasharray="67.92" stroke-dashoffset="67.92"&gt;
12            &lt;animate id="0" attributeName="stroke-dashoffset" values="67.92;0" dur="0.51s" fill="freeze" begin="0s;3005.click" /&gt;
13        &lt;/path&gt;
14        &lt;path d="M45,44.35c1.05,0,3.62,0.35,6.26,0.1c9.18-0.85,25.21-3.31,29.06-3.67c4.26-0.4,6.46,4.28,4.68,6.25C78.32,54.46,67.5,67,57.81,79.22" stroke-dasharray="87.4" stroke-dashoffset="87.4"&gt;
15            &lt;animate attributeName="stroke-dashoffset" values="87.4" fill="freeze" begin="3005.click" /&gt;
16            &lt;animate id="1" attributeName="stroke-dashoffset" values="87.4;0" dur="0.66s" fill="freeze" begin="0.end" /&gt;
17        &lt;/path&gt;
18        &lt;path d="M42.52,68.33c10.16,5.01,26.25,20.59,28.79,28.38" stroke-dasharray="41.01" stroke-dashoffset="41.01"&gt;
19            &lt;animate attributeName="stroke-dashoffset" values="41.01" fill="freeze" begin="3005.click" /&gt;
20            &lt;animate id="2" attributeName="stroke-dashoffset" values="41.01;0" dur="0.41s" fill="freeze" begin="1.end" /&gt;
21        &lt;/path&gt;
22    &lt;/g&gt;
23&lt;/g&gt;
24&lt;/svg&gt;

And here is the problem:
So, on the picture it's clear that the chained animation is not stopped when I click the pictue :(
enter image description here

ANSWER

Answered 2021-Dec-26 at 09:01

Instead of chaining animations off one another, have all the animations begin="0s; 3005.click". Then they will all reset when you click.

You can use keyPoints and keyTimes, to control when each of the animations starts. So you can still have your staggered starts.

1&lt;svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109" id="3005"&gt;
2&lt;g fill="none" stroke="#666" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"&gt;
3    &lt;g&gt;
4        &lt;path d="M50.75,19.5c0.1,1.3,0.37,3.74-0.19,5.21C43.57,43,32.73,60.29,14.5,75.04" /&gt;
5        &lt;path d="M45,44.35c1.05,0,3.62,0.35,6.26,0.1c9.18-0.85,25.21-3.31,29.06-3.67c4.26-0.4,6.46,4.28,4.68,6.25C78.32,54.46,67.5,67,57.81,79.22" /&gt;
6        &lt;path d="M42.52,68.33c10.16,5.01,26.25,20.59,28.79,28.38" /&gt;
7    &lt;/g&gt;
8&lt;/g&gt;
9&lt;g fill="none" stroke="#000" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"&gt;
10    &lt;g&gt;
11        &lt;path d="M50.75,19.5c0.1,1.3,0.37,3.74-0.19,5.21C43.57,43,32.73,60.29,14.5,75.04" stroke-dasharray="67.92" stroke-dashoffset="67.92"&gt;
12            &lt;animate id="0" attributeName="stroke-dashoffset" values="67.92;0" dur="0.51s" fill="freeze" begin="0s;3005.click" /&gt;
13        &lt;/path&gt;
14        &lt;path d="M45,44.35c1.05,0,3.62,0.35,6.26,0.1c9.18-0.85,25.21-3.31,29.06-3.67c4.26-0.4,6.46,4.28,4.68,6.25C78.32,54.46,67.5,67,57.81,79.22" stroke-dasharray="87.4" stroke-dashoffset="87.4"&gt;
15            &lt;animate attributeName="stroke-dashoffset" values="87.4" fill="freeze" begin="3005.click" /&gt;
16            &lt;animate id="1" attributeName="stroke-dashoffset" values="87.4;0" dur="0.66s" fill="freeze" begin="0.end" /&gt;
17        &lt;/path&gt;
18        &lt;path d="M42.52,68.33c10.16,5.01,26.25,20.59,28.79,28.38" stroke-dasharray="41.01" stroke-dashoffset="41.01"&gt;
19            &lt;animate attributeName="stroke-dashoffset" values="41.01" fill="freeze" begin="3005.click" /&gt;
20            &lt;animate id="2" attributeName="stroke-dashoffset" values="41.01;0" dur="0.41s" fill="freeze" begin="1.end" /&gt;
21        &lt;/path&gt;
22    &lt;/g&gt;
23&lt;/g&gt;
24&lt;/svg&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="109" height="109" viewBox="0 0 109 109" id="3005"&gt;
25&lt;g fill="none" stroke="#666" stroke-width="9" stroke-linecap="round" stroke-linejoin="round"&gt;
26    &lt;g&gt;
27        &lt;path d="M50.75,19.5c0.1,1.3,0.37,3.74-0.19,5.21C43.57,43,32.73,60.29,14.5,75.04" /&gt;
28        &lt;path d="M45,44.35c1.05,0,3.62,0.35,6.26,0.1c9.18-0.85,25.21-3.31,29.06-3.67c4.26-0.4,6.46,4.28,4.68,6.25C78.32,54.46,67.5,67,57.81,79.22" /&gt;
29        &lt;path d="M42.52,68.33c10.16,5.01,26.25,20.59,28.79,28.38" /&gt;
30    &lt;/g&gt;
31&lt;/g&gt;
32&lt;g fill="none" stroke="#000" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"&gt;
33    &lt;g&gt;
34        &lt;path d="M50.75,19.5c0.1,1.3,0.37,3.74-0.19,5.21C43.57,43,32.73,60.29,14.5,75.04" stroke-dasharray="67.92" stroke-dashoffset="67.92"&gt;
35            &lt;animate attributeName="stroke-dashoffset" values="67.92;0" dur="0.51s" fill="freeze" begin="0s;3005.click" /&gt;
36        &lt;/path&gt;
37        &lt;path d="M45,44.35c1.05,0,3.62,0.35,6.26,0.1c9.18-0.85,25.21-3.31,29.06-3.67c4.26-0.4,6.46,4.28,4.68,6.25C78.32,54.46,67.5,67,57.81,79.22" stroke-dasharray="87.4" stroke-dashoffset="87.4"&gt;
38            &lt;animate attributeName="stroke-dashoffset" values="87.4" fill="freeze" begin="3005.click" /&gt;
39            &lt;animate attributeName="stroke-dashoffset" values="87.4;87.4;0" keyTimes="0;0.444;1" dur="1.17s" fill="freeze" begin="0s;3005.click" /&gt;
40        &lt;/path&gt;
41        &lt;path d="M42.52,68.33c10.16,5.01,26.25,20.59,28.79,28.38" stroke-dasharray="41.01" stroke-dashoffset="41.01"&gt;
42            &lt;animate attributeName="stroke-dashoffset" values="41.01" fill="freeze" begin="3005.click" /&gt;
43            &lt;animate attributeName="stroke-dashoffset" values="41.01;41.01;0" keyTimes="0;0.75;1" dur="1.58s" fill="freeze" begin="0s;3005.click" /&gt;
44        &lt;/path&gt;
45    &lt;/g&gt;
46&lt;/g&gt;
47&lt;/svg&gt;

Source https://stackoverflow.com/questions/70475974

QUESTION

How to replace deprecated .animation() in SwiftUI?

Asked 2021-Nov-28 at 16:09

The .animation() modifier has been deprecated in iOS 15, but I'm not sure I understand how Xcode's suggested equivalent, animation(_:value:), works.

1.animation(.easeInOut(duration: 2)) // ⚠️'animation' was deprecated in iOS 15.0: Use withAnimation or animation(_:value:) instead.
2

How would I change my code to get rid of the warning?

ANSWER

Answered 2021-Oct-05 at 00:30

.animation now takes a second argument called value.

https://developer.apple.com/documentation/swiftui/view/animation(_:value:)

Source https://stackoverflow.com/questions/69443588

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Animation

Tutorials and Learning Resources are not available at this moment for Animation

Share this Page

share link

Get latest updates on Animation