我正要制作一个启动画面,我用VSCode而不是android studio制作了它,因为我使用的是flutter作为SDK。我手动导入了图像(拖放)并在styles.xml和launch_background.xml中进行了一些更改(因为它是启动屏幕)
String referenceParameter = System.getenv("refParamter1");
这是我的styles.xml
E:\Git\kene\android\app\src\main\res\drawable\launch_background.xml: AAPT: error: '@drawable\logos.png' is incompatible with attribute android:src (attr) reference|color.
E:\Git\kene\android\app\src\main\res\drawable\launch_background.xml:0: error: '@drawable\logos,png' is incompatible with attribute android:src (attr) reference|color.
error: failed linking file resources.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
...
这是我的launch_background.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<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>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
并且我可以确保文件名正确并且文件位于/ src / main / res / drawable
答案 0 :(得分:2)
从launch_background.xml内的文件名中删除.png,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@drawable\logos" />
</item>
</layer-list>
答案 1 :(得分:1)
将反斜杠替换为正斜杠 launch_background.xml位图android:src属性中的@ drawable / logos.png