无法在Android Studio上构建appcompat

时间:2015-02-06 23:14:07

标签: android gradle

每次我在Android Studio上开始一个新项目时我都遇到了这个问题。它开始让我生气了。

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.0.1'

    defaultConfig {
        applicationId "com.estudiotrilha.inevent"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.j256.ormlite:ormlite-android:4.45'
}

正如所料,由于我使用appcompatv21,我需要使用构建工具21 +来构建它。

当我构建时,我会收到400多个错误,看起来都像这样:

/Users/mauricio/AndroidstudioProjects/InEvent/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values/values.xml
Error:(609, 21) No resource found that matches the given name: attr 'windowFixedHeightMajor'.
Error:(596, 21) No resource found that matches the given name: attr 'windowFixedHeightMinor'.
Error:(590, 21) No resource found that matches the given name: attr 'windowFixedWidthMajor'.

这是我的styles.xml文件。也许它有助于解决问题。

<resources xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:inevent="http://schemas.android.com/apk/lib/com.estudiotrilha.view"
    xmlns:tools="http://schemas.android.com/tools">

    <style name="Floating" parent="@style/Theme.AppCompat.Light">
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>      
        <item name="android:backgroundDimEnabled">false</item>
    </style>    

    <style name="Transparent" parent="@android:style/Theme.NoTitleBar">
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowNoTitle">true</item>      
        <item name="android:backgroundDimEnabled">false</item>
    </style>

    <style name="NoActionBar" parent="@android:style/Theme.NoTitleBar">
        <item name="android:windowNoTitle">true</item>      
        <item name="android:backgroundDimEnabled">false</item>
    </style>

    <style name="Header">
        <item name="android:textColor">#0c5890</item>
        <item name="android:textSize">14sp</item>
    </style>

    <style name="Header2">
        <item name="android:textColor">#0c5890</item>
        <item name="android:textSize">16sp</item>
    </style>

    <!-- DARK ACTIONBAR -->
    <style name="DarkActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@color/backgroundDark</item>
        <item name="background">@color/backgroundDark</item>

        <item name="subtitleTextStyle">@style/TextColorDarkActionBar</item>
    </style>    

    <style name="SpinnerTextAppearenceDarkActionBar" parent="@style/Widget.AppCompat.DropDownItem.Spinner">
        <item name="android:textAppearance">@style/TextColorSpinnerDarkActionBar</item>
    </style>

    <style name="TextColorSpinnerDarkActionBar" parent="@style/Widget.AppCompat.Base.DropDownItem.Spinner">
        <item name="android:textColor">@color/textLight</item>
        <item name="android:textSize">16sp</item>
    </style>

    <style name="TextColorDarkActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:textColor">@color/textLight</item>
    </style>
    <!-- END -->

    <!-- PURPLE ACTIONBAR -->
    <style name="PurpleActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@color/backgroundPurple</item>
        <item name="background">@color/backgroundPurple</item>

        <item name="subtitleTextStyle">@style/TextColorDarkActionBar</item>
    </style>
    <!-- END -->

    <!-- WHITE ACTIONBAR -->
    <style name="WhiteActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="android:background">@color/background</item>
        <item name="background">@color/background</item>

        <item name="subtitleTextStyle">@style/TextColorWhiteActionBar</item>
    </style>

    <style name="TextColorWhiteActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
        <item name="android:textColor">@color/text</item>
    </style>
    <!-- END -->

    <style name="InEventTheme" parent="@style/Theme.AppCompat.Light">
        <item name="actionBarStyle">@style/WhiteActionBar</item>

        <item name="actionMenuTextColor">@color/text</item>

        <item name="setAcceptIcon">@drawable/ic_action_accept</item>
        <item name="setAddIcon">@drawable/ic_action_new</item>
        <item name="setCancelIcon">@drawable/ic_action_cancel</item>
        <item name="setEditIcon">@drawable/ic_action_edit</item>
        <item name="setFeedbackIcon">@drawable/ic_action_half_important</item>
        <item name="setMessageIcon">@drawable/ic_action_new_email</item>
        <item name="setNewEventIcon">@drawable/ic_action_new_event</item>
        <item name="setPresenceIcon">@drawable/ic_action_cc_bcc</item>
        <item name="setQuestionIcon">@drawable/ic_action_help</item>
        <item name="setRefreshIcon">@drawable/ic_action_refresh</item>
        <item name="setRemoveIcon">@drawable/ic_action_discard</item>
        <item name="setShareIcon">@drawable/ic_action_share</item>
    </style>

    <style name="WlPilatesTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="actionBarStyle">@style/DarkActionBar</item>

        <item name="actionMenuTextColor">@color/textLight</item>
        <item name="spinnerDropDownItemStyle">@style/SpinnerTextAppearenceDarkActionBar</item>
        <item name="android:spinnerDropDownItemStyle">@style/SpinnerTextAppearenceDarkActionBar</item>

        <item name="setAcceptIcon">@drawable/ic_action_accept_light</item>
        <item name="setAddIcon">@drawable/ic_action_new_light</item>
        <item name="setCancelIcon">@drawable/ic_action_cancel_light</item>
        <item name="setEditIcon">@drawable/ic_action_edit_light</item>
        <item name="setFeedbackIcon">@drawable/ic_action_half_important_light</item>
        <item name="setMessageIcon">@drawable/ic_action_new_email_light</item>
        <item name="setNewEventIcon">@drawable/ic_action_new_event_light</item>
        <item name="setPresenceIcon">@drawable/ic_action_cc_bcc_light</item>
        <item name="setQuestionIcon">@drawable/ic_action_help_light</item>
        <item name="setRefreshIcon">@drawable/ic_action_refresh_light</item>
        <item name="setRemoveIcon">@drawable/ic_action_discard_light</item>
        <item name="setShareIcon">@drawable/ic_action_share_light</item>
    </style>

    <style name="StartupABCTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle" tools:ignore="NewApi">@style/PurpleActionBar</item>
        <item name="actionBarStyle">@style/PurpleActionBar</item>

        <item name="actionMenuTextColor">@color/textLight</item>
        <item name="spinnerDropDownItemStyle">@style/SpinnerTextAppearenceDarkActionBar</item>
        <item name="android:spinnerDropDownItemStyle">@style/SpinnerTextAppearenceDarkActionBar</item>

        <item name="setAcceptIcon">@drawable/ic_action_accept_light</item>
        <item name="setAddIcon">@drawable/ic_action_new_light</item>
        <item name="setCancelIcon">@drawable/ic_action_cancel_light</item>
        <item name="setEditIcon">@drawable/ic_action_edit_light</item>
        <item name="setFeedbackIcon">@drawable/ic_action_half_important_light</item>
        <item name="setMessageIcon">@drawable/ic_action_new_email_light</item>
        <item name="setNewEventIcon">@drawable/ic_action_new_event_light</item>
        <item name="setPresenceIcon">@drawable/ic_action_cc_bcc_light</item>
        <item name="setQuestionIcon">@drawable/ic_action_help_light</item>
        <item name="setRefreshIcon">@drawable/ic_action_refresh_light</item>
        <item name="setRemoveIcon">@drawable/ic_action_discard_light</item>
        <item name="setShareIcon">@drawable/ic_action_share_light</item>
    </style>

</resources>

我不知道该怎么做,我按照每条指令行事,但仍然无法建立。 PS:当我使用appcompatv20时,它也会引发很多错误。

为什么在Android Studio中使用appcompat会如此苛刻?这是唯一一个我总是浪费时间来构建它的库。

0 个答案:

没有答案