无法构建android项目

时间:2016-05-11 14:37:48

标签: android android-studio gradle compiler-errors

我刚刚接手了一个没有任何文档的android项目,所以我的(第一个)工作是让应用程序构建。

我使用的是Android Studio 1.5.1

我的构建输出如下所示:

AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027stextColorLink\u0027.","sources":[{"file":"D:\\android\\jobmatch\\app\\src\\main\\res\\values\\styles.xml","position":{"startLine":47,"startColumn":4,"startOffset":2338,"endLine":54,"endColumn":12,"endOffset":2702}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027stextSize\u0027.","sources":[{"file":"D:\\android\\jobmatch\\app\\src\\main\\res\\values\\styles.xml","position":{"startLine":47,"startColumn":4,"startOffset":2338,"endLine":54,"endColumn":12,"endOffset":2702}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"No resource found that matches the given name: attr \u0027stextStyle\u0027.","sources":[{"file":"D:\\android\\jobmatch\\app\\src\\main\\res\\values\\styles.xml","position":{"startLine":47,"startColumn":4,"startOffset":2338,"endLine":54,"endColumn":12,"endOffset":2702}}],"original":"","tool":"AAPT"}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
    Execution failed for task ':app:processDebugResources'.
    > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\tr\AppData\Local\Android\sdk\build-tools\23.0.3\aapt.exe'' finished with non-zero exit value 1
 * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output

我没有包含所有错误,因为它继续存在关于缺少attr资源的类似错误。

我的gradle文件如下所示:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.appchance.jobmatcher"
        minSdkVersion 14
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:21.0.3'
    compile files('libs/android-support-v7-recyclerview.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/httpmime-4.1.2.jar')
    compile files('libs/listviewanimations_lib-core-slh_3.1.0.jar')
    compile files('libs/listviewanimations_lib-core_3.1.0.jar')
    compile files('libs/listviewanimations_lib-manipulation_3.1.0.jar')
    compile files('libs/systembartint-1.0.4.jar')
    compile 'com.android.support:appcompat-v7:+'
}

Style.xml:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="AppTheme" parent="AppTheme.Base" />

    <style name="AppTheme.Translucent" parent="AppTheme.Base">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
    </style>

    <style name="AppTheme.Base" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:colorForeground">@color/colorForeground</item>
        <item name="android:listChoiceIndicatorMultiple">@drawable/selector_check_box_empty</item>
        <item name="android:listChoiceIndicatorSingle">@drawable/selector_check_box_empty</item>
        <item name="actionMenuTextColor">@color/white</item>
        <item name="android:actionMenuTextColor">@color/white</item>
        <item name="sswitchStyle">@style/SwitchCustom</item>
    </style>

    <style name="ActionBarThemeOverlay" parent="">
        <item name="android:textColorPrimary">#fff</item>
        <item name="colorControlNormal">#fff</item>
        <item name="colorControlHighlight">#8fff</item>
        <item name="selectableItemBackground">@drawable/ab_item_background</item>
    </style>

    <style name="CustomSwitchTextAppearance" parent="TextAppearance.AppCompat.Widget.Switch">
        <item name="android:textColor">@color/white</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">11sp</item>
    </style>

    <style name="SwitchCustom">
        <item name="strack">@drawable/custom_switch_track</item>
        <item name="sthumb">@drawable/custom_switch_thumb</item>
        <item name="stextOn">@string/textOn</item>
        <item name="stextOff">@string/textOff</item>
        <item name="sthumbTextPadding">6dip</item>
        <item name="sswitchMinWidth">60dip</item>
        <item name="sswitchPadding">0dip</item>
        <item name="sswitchTextAppearance">@style/TextAppearanceSwitch</item>
    </style>

    <style name="TextAppearanceSwitch">
        <item name="stextColor">@color/white</item>
        <item name="stextColorHighlight">@color/white</item>
        <item name="stextColorHint">@color/white</item>
        <item name="stextColorLink">@color/white</item>
        <item name="stextSize">11sp</item>
        <item name="stextStyle">1</item>
    </style>

</resources>

我已经找到了一个解决方案但是找不到一个,希望有人可以给我一些指导,因为我是Android开发的新手。

2 个答案:

答案 0 :(得分:0)

1&GT;清理你的项目并运行

如果不是

2 - ;使用add into build.gradle文件

dexOptions {
        javaMaxHeapSize "4g"
    }

答案 1 :(得分:0)

只需将bcrypt更改为compileSdkVersion 'Google Inc.:Google APIs:23'