This is NOT about creating a "Splash Screen" which is loaded after app loads.
I am trying to make animated gifs work in android's launch screen (Section "Define a launch theme")
When I add a non animated image, launch_background.jpg
it appears fine. But when I add a gif image with animation (launch_background.gif
), it appears as static image.
I followed these steps but when I run the flutter app, I get this error:
Launching lib\main.dart on SM J610F in debug mode...
Initializing gradle...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
Output: E:\flutterProjects\app_name\app_name\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:179: error: :pl.droidsonroids.gif.GifTextView>.
Command: C:\Users\r\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\15cdf2a9fa9e4ee473d47c95fa8e0c69\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
E:\flutterProjects\app_name\app_name\build\app\intermediates\res\merged\debug \
E:\flutterProjects\app_name\app_name\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #1
Output: C:\Users\r\.gradle\caches\transforms-1\files-1.1\core-1.0.0.aar\e2765643361afa85f13c55b475d0d315\res\values\values.xml:167:5-117: AAPT: error: :pl.droidsonroids.gif.GifTextView>.
Command: C:\Users\r\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\15cdf2a9fa9e4ee473d47c95fa8e0c69\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
E:\flutterProjects\app_name\app_name\build\app\intermediates\res\merged\debug \
E:\flutterProjects\app_name\app\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://goo. gl/CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Resolving dependencies...
Running Gradle task 'assembleDebug'...
Finished with error: Gradle task assembleDebug failed with exit code 1
[1]: https://flutter.dev/docs/development/add-to-app/android/add-splash-screen
[2]: https://stackoverflow.com/a/39871506/1291122
My app/src/main/res/values/styles.xml
looks like this:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<!-- <item name="android:windowBackground">@drawable/launch_background</item>-->
<pl.droidsonroids.gif.GifTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/launcher_image"
/>
</style>
</resources>
And I have a launcher_image.gif in res/mipmap-hdpi folder.
I would be happy if I could make this android plugin work, or if I could figure out a way to make animated gif work in the "Launch Screen". Google is full of tutorials about "Splash Screen" gif animations. But very few address the issue of doing it in a "Launch Screen" on android.