Error Compiling Project in Android Studio [duplica

2019-09-12 01:56发布

问题:

This question is an exact duplicate of:

  • Error in Compiling : Android Studio 1 answer

I can't compile a project in android studio.I get 4 errors as shown below.

My xml file that contains the error is :

<style name="Theme.Bootstrap.Dark" parent="@style/Theme.AppCompat">
    <item name="android:windowBackground">@color/pager_background</item>
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="background">@drawable/actionbar_background</item>
    <item name="android:background">@drawable/actionbar_background</item>
</style>

Errors are :

Error:(5, -1) android-apt-compiler: [main] D:\android\tinynote\app\src\main\res\values\theme.xml:5: error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat'.

Error:(7, -1) android-apt-compiler: [main] D:\android\tinynote\app\src\main\res\values\theme.xml:7: error: Error: No resource found that matches the given name: attr 'actionBarStyle'.

Error:(11, -1) android-apt-compiler: [main] D:\android\tinynote\app\src\main\res\values\theme.xml:11: error: Error retrieving parent for item: No resource found that matches the given name '@style/Widget.AppCompat.ActionBar.Solid'.

Error:(12, -1) android-apt-compiler: [main] D:\android\tinynote\app\src\main\res\values\theme.xml:12: error: Error: No resource found that matches the given name: attr 'background'.

I need to modify a project built on IntelliJ. I have imported it in Android-Studio and I can't compile it.The project built earlier worked fine. Please help by giving some step-by-step solution.I am stuck in this for 4 hrs now.Thanks a lot for your help.

回答1:

You are most probably missing AppCompat library which comes in support directory.AppCompat is a library project. You need to reference the library project in your android project.use this link to add your support package link to add app compat

you are using this parent="@style/Theme.AppCompat" instead use this parent="@android:style/Theme.AppCompat".i guess they have typo in the docs file