添加com.android.support:recyclerview-v7:28.0.0-alpha1后项目编译报错求助
Hey there, let's get this sorted out quickly! The error you're seeing is caused by a version mismatch between your Android Support Library components. Here's what's happening and how to fix it:
Why This Happens
You added com.android.support:recyclerview-v7:28.0.0-alpha1 to your project, but your existing appcompat-v7 is still stuck on version 25.3.1. A golden rule for Android Support Libraries is that all components must use the exact same version—mixing versions creates resource conflicts like the missing fontStyle attribute you're encountering.
Solutions to Try
1. Upgrade All Support Libraries to Match RecyclerView's Version
Update your appcompat-v7 (and any other Support libraries you're using) to 28.0.0-alpha1, and align your compile/target SDK versions with API 28:
In your app-level build.gradle file:
android { compileSdkVersion 28 defaultConfig { targetSdkVersion 28 // Keep your other existing configs (minSdkVersion, etc.) here } } dependencies { // Update appcompat to match RecyclerView's version implementation 'com.android.support:appcompat-v7:28.0.0-alpha1' // Your existing RecyclerView dependency implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1' // Don't forget to update other Support libraries (like design, cardview) to 28.0.0-alpha1 too! }
2. Downgrade RecyclerView to Match Your Existing AppCompat Version
If you don't want to jump to the unstable alpha version of API 28, you can instead downgrade RecyclerView to match your current appcompat-v7:25.3.1:
dependencies { implementation 'com.android.support:appcompat-v7:25.3.1' // Downgrade RecyclerView to match your existing AppCompat version implementation 'com.android.support:recyclerview-v7:25.3.1' }
Quick Note
Alpha versions like 28.0.0-alpha1 can have unexpected bugs. If you're working on a production project, consider using the latest stable version of the Support Library (like 28.0.0, the final stable release of the old Support Library) or migrating to AndroidX for long-term, maintained support.
内容的提问来源于stack exchange,提问作者Stanly T

