如何阅读 "failed linking file resources" 错误消息?
How do I read "failed linking file resources" error messages?
我经常自发地得到这些,我永远无法刻意解决它们。这是构建日志:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
Output: X:\Documents\All\Creative\Programming\Projects\Theo\app\src\main\res\layout\activity_login.xml:74: error: resource integer/login (aka org.andrewedgar.theo:integer/login) not found.
error: failed linking file resources.
我看到对我的一个 activity 布局 (activity_login) 的引用,但我已经好几个星期没有碰过那个文件或其对应的 class 了。甚至第 74 行也没有:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="org.andrewedgar.theo.LoginActivity">
<ImageView
android:id="@+id/imageView2"
android:layout_width="286dp"
android:layout_height="100dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/textInputLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/logo" />
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:textColorHint="@color/hintColor"
app:layout_constraintBottom_toTopOf="@+id/textInputLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito"
android:hint="@string/prompt_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/hintColor"
android:textIsSelectable="false" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:textColorHint="@color/hintColor"
app:layout_constraintBottom_toTopOf="@+id/login_sign_in_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito"
android:hint="@string/prompt_password"
android:imeActionId="@integer/login"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/hintColor" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/login_sign_in_button"
style="?android:textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="@android:color/background_light"
android:fontFamily="@font/nunito_bold"
android:onClick="signInExistingUser"
android:text="@string/action_sign_in_short"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/login_register_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/login_register_button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="@color/colorPrimary"
android:fontFamily="@font/nunito_bold"
android:onClick="registerNewUser"
android:text="@string/action_register"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
恢复到我提交时有效的版本也没有解决问题。使 Caches/Restart 和 Clean/Rebuild 无效无效。是否有针对此类错误的典型解决方案?
error: resource integer/login (aka org.andrewedgar.theo:integer/login) not found
。看起来你以前有这个资源,但现在你没有了。
您需要删除 @integer/login
并执行 clean
和 build
。如果没有帮助,请执行:
File -> Invalidate Caches/Restart
或者您可以将登录资源添加到 values
文件夹中的 xml 文件中。
您引用的属性 "@integer/login"
很可能不存在于您的项目中。
事实上,错误说明如下:
error: resource integer/login (aka org.andrewedgar.theo:integer/login) not found.
通常,此类错误与 xml 有关,并指出您在某处使用了无法识别的属性。
resource integer/login
not found.
如何添加缺少的资源,类型为 integer
,名称为 login
?
例如。与 res/values/numerical.xml
相似:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="login">1</integer>
</resources>
我经常自发地得到这些,我永远无法刻意解决它们。这是构建日志:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugResources'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:103)
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
Output: X:\Documents\All\Creative\Programming\Projects\Theo\app\src\main\res\layout\activity_login.xml:74: error: resource integer/login (aka org.andrewedgar.theo:integer/login) not found.
error: failed linking file resources.
我看到对我的一个 activity 布局 (activity_login) 的引用,但我已经好几个星期没有碰过那个文件或其对应的 class 了。甚至第 74 行也没有:
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="org.andrewedgar.theo.LoginActivity">
<ImageView
android:id="@+id/imageView2"
android:layout_width="286dp"
android:layout_height="100dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/textInputLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/logo" />
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:textColorHint="@color/hintColor"
app:layout_constraintBottom_toTopOf="@+id/textInputLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<AutoCompleteTextView
android:id="@+id/login_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito"
android:hint="@string/prompt_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/hintColor"
android:textIsSelectable="false" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:textColorHint="@color/hintColor"
app:layout_constraintBottom_toTopOf="@+id/login_sign_in_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<EditText
android:id="@+id/login_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/nunito"
android:hint="@string/prompt_password"
android:imeActionId="@integer/login"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/hintColor" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/login_sign_in_button"
style="?android:textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="@android:color/background_light"
android:fontFamily="@font/nunito_bold"
android:onClick="signInExistingUser"
android:text="@string/action_sign_in_short"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/login_register_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/login_register_button"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:background="@color/colorPrimary"
android:fontFamily="@font/nunito_bold"
android:onClick="registerNewUser"
android:text="@string/action_register"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
恢复到我提交时有效的版本也没有解决问题。使 Caches/Restart 和 Clean/Rebuild 无效无效。是否有针对此类错误的典型解决方案?
error: resource integer/login (aka org.andrewedgar.theo:integer/login) not found
。看起来你以前有这个资源,但现在你没有了。
您需要删除 @integer/login
并执行 clean
和 build
。如果没有帮助,请执行:
File -> Invalidate Caches/Restart
或者您可以将登录资源添加到 values
文件夹中的 xml 文件中。
您引用的属性 "@integer/login"
很可能不存在于您的项目中。
事实上,错误说明如下:
error: resource integer/login (aka org.andrewedgar.theo:integer/login) not found.
通常,此类错误与 xml 有关,并指出您在某处使用了无法识别的属性。
resource
integer/login
not found.
如何添加缺少的资源,类型为 integer
,名称为 login
?
例如。与 res/values/numerical.xml
相似:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="login">1</integer>
</resources>