Android资源链接失败求助:项目无法构建,缺失系统属性
Hey there, let's work through these resource linking issues you're facing—they're usually tied to mismatched SDK versions or missing default resources, so we can sort this out step by step.
First, Address the Missing Attribute Errors
The errors about android:attr/dialogCornerRadius, fontVariationSettings, and ttcIndex are directly related to your project's Compile SDK Version:
fontVariationSettingsandttcIndexwere introduced in Android API 26dialogCornerRadiuswas added in Android API 28
If your project is compiling against an SDK version lower than these, the build tool can't find these attributes. Here's how to fix it:
- Open your module-level
build.gradlefile (usuallyapp/build.gradle). - Update the
compileSdkVersionandtargetSdkVersionto at least 28 (or a newer stable version like 33 or 34):
android { compileSdkVersion 33 // Use a version >=28 defaultConfig { targetSdkVersion 33 // Match this to your compileSdkVersion // ... other configs like minSdkVersion } }
- Sync your project with Gradle files (click the "Sync Now" prompt that appears).
Resolve the Resource Removal Warnings
The warnings about removing logOut and wrongNumberWarning mean these string resources don't have a default value in your main values/strings.xml file—they might only exist in language-specific folders (like values-es or values-fr). To fix this:
- Navigate to
res/values/strings.xml. - Add default versions of these strings:
<string name="logOut">Log Out</string> <string name="wrongNumberWarning">Please enter a valid number</string>
Use placeholder text that makes sense for your app—this ensures the resources exist for all device locales.
Additional Troubleshooting Steps
If the above fixes don't work, try these:
- Clean & Rebuild: Go to
Build > Clean Project, thenBuild > Rebuild Projectto clear cached build files that might be causing conflicts. You can also run these commands in the terminal:
./gradlew clean ./gradlew assembleDebug
- Check Dependencies: If you're using third-party libraries, some might be built against a newer SDK version. Verify that your dependencies are compatible with your updated
compileSdkVersion, or update the libraries to their latest versions.
These steps should resolve the resource linking failures and warnings you're seeing.
内容的提问来源于stack exchange,提问作者Sid

