【发布时间】:2019-12-24 00:26:35
【问题描述】:
这不是关于创建在应用加载后加载的“启动画面”。
我正在尝试使动画 gif 在 android 的 launch screen 中工作(“定义启动主题”部分)
当我添加一个非动画图像时,launch_background.jpg 它看起来很好。但是当我添加带有动画的 gif 图像 (launch_background.gif) 时,它显示为静态图像。
我关注了these steps,但是当我运行颤振应用程序时,我收到了这个错误:
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
我的app/src/main/res/values/styles.xml 看起来像这样:
<?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>
我在 res/mipmap-hdpi 文件夹中有一个 launcher_image.gif。
如果我能让这个 android 插件工作,或者如果我能想办法让动画 gif 在“启动屏幕”中工作,我会很高兴。谷歌充满了关于“闪屏”gif动画的教程。但很少有人解决在 android 上的“启动屏幕”中执行此操作的问题。
【问题讨论】: