Android项目修改minSdk为26后资源链接失败求助
Hey there, let's work through these resource linking errors together—since this is your first Android project, I'll keep things clear and actionable, no jargon overload.
1. Resolve android:attr/dialogCornerRadius, fontVariationSettings, and ttcIndex Errors
These attributes are part of Android API Level 28 (Android 9.0) and newer. Even though you set minSdkVersion to 26, if your project's compileSdkVersion or targetSdkVersion is lower than 28, the compiler won't recognize these newer system attributes.
Here's how to fix it:
- Open your app-level
build.gradle(Module: app) file. - Update
compileSdkVersionandtargetSdkVersionto at least 28 (I recommend using a newer stable version like 33 or 34 for better compatibility):
android { compileSdkVersion 34 // Or 33/28—use the latest stable version you have installed defaultConfig { applicationId "com.example.myapplication" minSdkVersion 26 targetSdkVersion 34 // ... other existing settings } // ... other configurations }
- Sync your project with Gradle (click the "Sync Now" prompt that pops up) and try rebuilding.
2. Fix Missing Drawable Resources (edit_text_background_dark_round, ic_down_arrow)
These errors mean your project can't locate the specified drawable files. Try these checks:
- Navigate to your project's
res/drawable(orres/drawable-v21, etc.) folders and verify if these files exist. If they're missing:- If you created these drawables yourself, restore them from a backup or recreate them using Android Studio's Vector Asset Studio (right-click
res/drawable > New > Vector Asset). - If these drawables come from a third-party library (like Firebase UI or another dependency), ensure the library version matches your updated
compileSdkVersion. You might need to bump the library's version in yourbuild.gradledependencies block.
- If you created these drawables yourself, restore them from a backup or recreate them using Android Studio's Vector Asset Studio (right-click
- Double-check file names: Android is case-sensitive, so make sure the filename matches exactly what's referenced (e.g.,
ic_down_arrow.xmlinstead ofIC_Down_Arrow.xml).
3. Additional Troubleshooting Steps
If the above fixes don't resolve the issue, try these common go-to fixes for resource conflicts:
- Invalidate Caches and Restart: Go to
File > Invalidate Caches... > Invalidate and Restart. This clears Android Studio's cached resources that might be causing weird conflicts. - Clean and Rebuild: Click
Build > Clean Project, thenBuild > Rebuild Projectto rebuild all resources from scratch.
If you hit any roadblocks while trying these steps, just let me know—I’m happy to walk you through further details!
内容的提问来源于stack exchange,提问作者davidsumyhero

