且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:渲染问题无法找到以下类android.support.v7.internal.widget.ActionBarOverlayLayout

更新时间:2022-10-22 19:16:00

Fix res/values/styles.xml 像这样:

按要求详细解释:Theme.AppCompat.Light.DarkActionBar 无论如何都是超类Base 的子类.Ctrl+单击(Android Studio),您将被带到源代码:

<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>

我们没有改变任何东西,我们只是更精确地定义它.

I am just a beginner to android app development. When i created a new project on Android Studio 1.1.0, it gives up this error "rendering problems The following classes could not be found android.support.v7.internal.widget.ActionBarOverlayLayout"

Now i have searched about this on google, and i found possibly 3 solutions given by most of the people.

They say:

  1. Either change the api (from preview window pane) from 22 to 21, or

  2. Change the App Theme from "Project Theme" to any other theme.

  3. be sure to have imported right appcompat-v7 library in your project structure -> dependencies, Refer these steps: Add the support library feature project identifier to the dependencies section. For example, to include the appcompat project add compile "com.android.support:appcompat-v7:18.0.+" to the dependencies section, as shown in the following example:

dependencies {
    ...
    compile "com.android.support:appcompat-v7:18.0.+" }

Note: My android support lib is up-to-date (installed it using SDK Manager).

Following first two steps, removed the error. But I feel that these are not the permanent solutions, the Second step seems just like a temporary workaround. I have doubts about the First step also, that if to remove the error, we change api from 22 to 21, then at the end, our app wont work in Android 5.1.1(API 22), it would be restricted to Android 5.0.1 and below only (API 21). Are my doubts valid? Regarding the third step, is it the permanent solution to this problem?

P.S : Sorry for mismatching tags, wasn't allowed to add exact tags due to site reputation

Fix res/values/styles.xml like so:

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"/>

Detailed explanation as requested: Theme.AppCompat.Light.DarkActionBar is a subclass of the superclass Base anyway. Ctrl+click (Android Studio) on it and you will be taken to the source:

<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />

We didn't change anything, we just defined it more precisely.