我在可绘制文件夹中添加了一个形状,如下所示;
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="#7A828D" android:width="1dp"/>
<solid android:color="@color/white" />
<corners android:radius="8dp"/>
</shape>
然后我在我的布局中加入了这个;
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@drawable/shape_info_bg_1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/sl_userid"
android:layout_marginBottom="20dp">
<ImageView
android:id="@+id/img_info"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/ico_info"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="20dp"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="asdasdasdasda"
android:fontFamily="@font/medium"
android:layout_marginEnd="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/img_info"
app:layout_constraintTop_toTopOf="@id/img_info"
app:layout_constraintBottom_toBottomOf="@+id/img_info"
android:layout_marginStart="15dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
当我在真实的设备上构建时,我得到了以下错误;
...\src\main\res\layout\activity_login.xml:41: AAPT: error: resource drawable/shape_info_bg_1 (aka com.xxxxx:drawable/shape_info_bg_1) not found.
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\xxxx\\Documents\\xxxx\\app\\src\\main\\res\\layout\\activity_login.xml","position":{"startLine":40}}],"original":"C:\\Users\\xxxx\\Documents\\xxxx\\app\\src\\main\\res\\layout\\activity_login.xml:41: AAPT: error: resource drawable/shape_info_bg_1 (aka com.xxxx:drawable/shape_info_bg_1) not found.\n ","tool":"AAPT"}
> Task :app:mergeExtDexDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\xxxxx\Documents\xxxxx\app\src\main\res\layout\activity_login.xml:41: AAPT: error: resource drawable/shape_info_bg_1 (aka com.xxxxx/shape_info_bg_1) not found.
* 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
BU�LD FAILED in 12s
我总是用这种方式添加形状,没有问题。我不能解决这个问题。我以前从未见过面,你能帮我吗?
发布于 2020-05-31 02:37:53
Project.
发布于 2020-05-31 03:44:33
只需点击清理项目,然后重新构建即可
它一定会解决你的问题。如果不能,只需删除您添加的文件,重新构建项目,再次添加文件并构建项目
发布于 2021-08-13 18:44:58
我在我继承的一个项目中遇到了这个错误,这个项目刚刚从NativeScript 4更新到NativeScript 6。
对我来说,解决方案是将资源文件夹移动到正确的位置,以便构建可以拾取它们,并将它们添加到输出构建文件夹:
'app/App_Resources/Android/' to 'app/App_Resources/Android/src/main/'
'app/App_Resources/Android/drawable...' to 'app/App_Resources/Android/src/main/res/drawable...'
'app/App_Resources/Android/values' to 'app/App_Resources/Android/src/main/res/values'
费什
https://stackoverflow.com/questions/61106645
复制相似问题