You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加com.android.support:recyclerview-v7:28.0.0-alpha1后项目编译报错求助

Fix for "resource android:attr/fontStyle not found" After Adding 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 10:07:45