Android资源链接失败的Android studio 3.3

问题描述 投票:1回答:5

我收到了这个错误

“Android资源链接失败C:\ Users \ xervice111 \ AndroidStudioProjects \ ud843-QuakeReport-starting-point \ app \ src \ main \ res \ layout \ list_item.xml:10:error:resource drawable / magnitude_circle(aka com.example。 android.quake

报告:drawable / magnitude_circle)未找到。错误:链接文件资源失败。“

This is the error我添加了一个名为“magnitudeCircle.xml”的可绘制资源文件。我做过像清洁项目,重建项目,无效和重启等事情,但错误仍然存​​在...

This is my magnitubeCircle.xml file

<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Background circle for the magnitude value -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="@color/magnitude1" />
    <size
        android:width="36dp"
        android:height="36dp" />
    <corners android:radius="18dp" />
</shape>
android android-gradle drawable xml-drawable
5个回答
1
投票

试试这个

<?xml version="1.0" encoding="utf-8"?>

<!-- Background circle for the magnitude value -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="@color/magnitude1" />
    <size
        android:width="36dp"
        android:height="36dp" />
    <corners android:radius="18dp" />
</shape>

0
投票

尝试从xml中删除一行

<?xml version="1.0" encoding="utf-8"?>

你的xml中有两个导入行。


0
投票

此错误属于以下行:

<?xml version="1.0" encoding="utf-8"?>

因为我们不能在单个文件中使用此标记两次<click here>。

所以,删除此行并尝试以下代码:

<?xml version="1.0" encoding="utf-8"?>
<!-- Background circle for the magnitude value -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/magnitude1" />
<size
    android:width="36dp"
    android:height="36dp" />
<corners android:radius="18dp" />
</shape>

0
投票

我认为问题出在你的“list_item.xml”文件中。错误是list_item.xml文件的第10行。构建器无法从项目中找到“drawable / magnitude_circle”项。所以,

1)如果你没有在drawable资源文件中添加“magnitude_circle”文件,而不是先将该文件添加到drawable中,然后尝试构建项目。

2)如果你已经在drawable中有该文件,那么将drawable/magnitude_circle替换为@drawable/magnitude_circle


0
投票

从xml中删除此行:

<?xml version="1.0" encoding="utf-8"?>

如果不起作用,请创建新文件夹'drawable-v28(您的版本)',然后将xml文件从'drawable'复制到它。希望对你有效。

© www.soinside.com 2019 - 2024. All rights reserved.