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

Android Studio 3.1稳定版Theme与?attr/actionBarSize属性报错求助

Hey there, let’s tackle these two issues you’re facing in Android Studio 3.1 stable version one by one:

Issue 1: Error when selecting Android system Theme in styles.xml

Here are some troubleshooting steps to fix this:

  • First, check your module-level build.gradle file. Make sure the version of your AppCompat/Support Library matches your compileSdkVersion. For example, if compileSdkVersion is set to 27, your appcompat dependency should be something like com.android.support:appcompat-v7:27.1.1—mismatched versions often cause theme-related errors.
  • Try syncing your project with Gradle files: Go to File > Sync Project with Gradle Files. Sometimes cached Gradle data messes up theme recognition.
  • Clean and rebuild your project: Run Build > Clean Project first, then Build > Rebuild Project. This clears old build caches that might be causing resource conflicts.
  • Verify your styles.xml root theme: If you’re using the AppCompat library, ensure your theme inherits from an AppCompat base (like Theme.AppCompat.Light.DarkActionBar) instead of a native Android theme (e.g., android:Theme.Holo.Light). Native themes can clash with AppCompat components.
Issue 2: Error using ?attr/actionBarSize in layout files

Try these fixes for the actionBarSize attribute error:

  • Confirm your Activity class extends AppCompatActivity (not the native Activity). The ?attr/actionBarSize attribute is part of the AppCompat library, so it won’t work with plain native Activities.
  • Check your app’s theme in styles.xml: Make sure your theme inherits from an AppCompat variant (e.g., Theme.AppCompat.Light). If you’re using a native Android theme, this attribute won’t be recognized.
  • Sync and rebuild your project again—same as the first issue, cached build files can prevent the attribute from being resolved correctly.
  • If you don’t want to use AppCompat, you can switch to the native version: android.R.attr.actionBarSize (note the android namespace prefix). This works with native Android themes, but limits you to older theme systems.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 07:06:07