You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android Studio构建Gradle时出现AAPT2资源链接失败问题求助

Fixing Android Resource Linking Failed Error in Your Project

Hey there, let's get your build back on track! Looking at your error logs, there are two key things to address:

1. Direct Cause: Typo in XML Attribute

The critical error here is a simple typo in your layout file. Check this line from your log:

/home/sakhile/Downloads/ud851-Exercises-student/Lesson03-Green-Recycler-View/Tasker/app/src/main/res/layout/service_list.xml:47: error: attribute android:textinearLayoutStyle not found.

You accidentally added an extra t to the attribute name — it should be android:linearLayoutStyle instead of android:textinearLayoutStyle. That's why AAPT2 can't locate the attribute and throws the linking error.

2. Step-by-Step Fixes

Follow these steps to resolve the issue:

  • Open the service_list.xml file mentioned above, jump to line 47, and correct that typo (remove the extra t in textinear).
  • Clean and rebuild your project to ensure changes take effect:
    • In Android Studio: Go to Build > Clean Project, then Build > Rebuild Project.
    • Or via command line: Run ./gradlew clean build from your project root directory.
  • If you still see the ResourceType warnings after fixing the typo, try deleting your Gradle cache to clear any corrupted resource files. Remove the contents of /home/sakhile/.gradle/caches/ and rebuild again.

Why the ResourceType Warnings Appeared

Those W/ResourceType warnings are a side effect of the invalid attribute. When AAPT2 hits the unrecognized textinearLayoutStyle attribute, it messes up its resource index calculations, leading to those "entry index beyond entryCount" messages. Fixing the typo will resolve these warnings automatically.

内容的提问来源于stack exchange,提问作者Sakhispot

火山引擎 最新活动