Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.oupson:kapng-android:1.0.10'
}
dependencies {
implementation("com.github.oupson:kapng-android:1.0.10")
}
<dependency>
<groupId>com.github.oupson</groupId>
<artifactId>kapng-android</artifactId>
<version>1.0.10</version>
</dependency>
libraryDependencies += "com.github.oupson" % "kapng-android" % "1.0.10"
:dependencies [[com.github.oupson/kapng-android "1.0.10"]]

val imageUrl = URL("https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png")
ApngDecoder.decodeApngAsyncInto(context, imageUrl, imageView)
You can load a file, an uri, a resource int, an url, or an inputStream.
ApngDecoder.decodeApngAsyncInto(context, imageUrl, imageView, callback = object : ApngDecoder.Callback {
override fun onSuccess(drawable: Drawable) { println("Success !") }
override fun onError(error: Exception) { println("Error : $error") }
})
val output : OutputStream = FileOutputStream("res.png") // An OutputStream (ex : a FileOutputStream)
val maxWidth : Int = 256 // The width of your image (ex : 256)
val maxHeight : Int = 256// The height of your image (ex : 256)
val nFrame : Int = 2 // Number of frame (ex : 2)
val inputFrame1 : InputStream = FileInputStream("frame1.png") // Input stream of your frame 1 (ex : a FileInputStream)
val inputFrame2 : InputStream = FileInputStream("frame2.png") // Input stream of your frame 2 (ex : a FileInputStream)
val encoder = ApngEncoder(output, maxWidth, maxHeight, nFrame)
encoder.writeFrame(inputFrame1)
inputFrame1.close()
encoder.writeFrame(inputFrame2, delay=500f) // With delay ! Default is 1000ms
inputFrame2.close()
encoder.writeEnd()
output.close()
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation 'com.github.oupson:Kapng-Android:1.0.11'
}
## Or put the aar file in /libs/ and verify that you have :
dependencies {
implementation fileTree(include: ['*.aar'], dir: 'libs')
}