构建singed apk时出错,找不到与给定名称匹配的资源

时间:2017-02-28 20:49:30

标签: java android android-build

我正在尝试发布我的应用。所以我在Android Studio中创建了一个有罪的APK。

by build>>生成有罪的APK>>填写所有表格并开始建设。

然后它出现了一些错误。已经尝试删除代码,但后来我在代码的某些部分出现了新的错误。所以我认为这比仅仅注释掉代码更难。

这个问题的奇怪部分,当我刚建立apk时。直接在手机上运行应用程序。它根本不会出错。

dexOptins就在那里,因为第一次正常构建使java失去了memeory异常。已经尝试过compileSDKVersion 23和buildtoolversion 23.0.0,但没有做任何事情。

这里是文件和错误:

错误:

        Error:(1264, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1265, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1271, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1272, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1278, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1279, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1286, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1287, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1264, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1265, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1271, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1272, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1278, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1279, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:(1286, 21) No resource found that matches the given name: attr 'colorBackground'.
Error:(1287, 21) No resource found that matches the given name: attr 'colorTintedBackground'.
Error:Execution failed for task ':app:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

获取错误的部分代码

     <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorBackground">@color/colorBackground</item>
    <item name="colorTintedBackground">@color/colorTintedBackground</item>
</style>


<style name="AppTheme.Dark" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/darkTheme_colorPrimary</item>
    <item name="colorPrimaryDark">@color/darkTheme_colorPrimaryDark</item>
    <item name="colorAccent">@color/darkTheme_colorAccent</item>
    <item name="colorBackground">@color/darkTheme_colorBackground</item>
    <item name="colorTintedBackground">@color/darkTheme_colorTintedBackground</item>
</style>

<style name="AppTheme.Classic" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/classic_colorPrimary</item>
    <item name="colorPrimaryDark">@color/classic_colorPrimaryDark</item>
    <item name="colorAccent">@color/classic_colorAccent</item>
    <item name="colorBackground">@color/classic_colorBackground</item>
    <item name="colorTintedBackground">@color/classic_colorTintedBackground</item>
</style>


<style name="AppTheme.Classic.Dark" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/classic_darkTheme_colorPrimary</item>
    <item name="colorPrimaryDark">@color/classic_darkTheme_colorPrimaryDark</item>
    <item name="colorAccent">@color/classic_darkTheme_colorAccent</item>
    <item name="colorBackground">@color/classic_darkTheme_colorBackground</item>
    <item name="colorTintedBackground">@color/classic_darkTheme_colorTintedBackground</item>
    <item name="android:textColorPrimary">@android:color/white</item>
</style>

<style name="AppTheme.NoStatusBar" parent="AppTheme.NoActionBar">
    <item name="android:windowNoTitle">true</item>

</style>

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.NoActionBar.Classic" parent="AppTheme.Classic">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

//

<style name="AppTheme.NoActionBar.Dark" parent="AppTheme.Dark">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.NoActionBar.Classic.Dark" parent="AppTheme.Classic.Dark">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

和颜色文件:

            <color name="darkTheme_colorPrimary">#2196F3</color>
    <color name="darkTheme_colorPrimaryDark">#1E88E5</color>
    <color name="darkTheme_colorAccent">#2196F3</color>
    <color name="darkTheme_colorBackground">#303030</color>
    <color name="darkTheme_colorTintedBackground">#424242</color>

    <color name="classic_colorPrimary">#607d8b</color>
    <color name="classic_colorPrimaryDark">#455a64</color>
    <color name="classic_colorAccent">#455a64</color>
    <color name="classic_colorBackground">@android:color/transparent</color>
    <color name="classic_colorTintedBackground">#cdcdcd</color>

    <color name="classic_darkTheme_colorPrimary">#37474f</color>
    <color name="classic_darkTheme_colorPrimaryDark">#263238</color>
    <color name="classic_darkTheme_colorAccent">#90a4ae</color>
    <color name="classic_darkTheme_colorBackground">#303030</color>
    <color name="classic_darkTheme_colorTintedBackground">#263238</color>

        <color name="darkTheme_colorPrimary">#2196F3</color>
<color name="darkTheme_colorPrimaryDark">#1E88E5</color>
<color name="darkTheme_colorAccent">#2196F3</color>
<color name="darkTheme_colorBackground">#303030</color>
<color name="darkTheme_colorTintedBackground">#424242</color>
    <color name="classic_colorPrimary">#607d8b</color>
    <color name="classic_colorPrimaryDark">#455a64</color>
    <color name="classic_colorAccent">#455a64</color>
    <color name="classic_colorBackground">@android:color/transparent</color>
    <color name="classic_colorTintedBackground">#cdcdcd</color>
    <color name="classic_darkTheme_colorPrimary">#37474f</color>
    <color name="classic_darkTheme_colorPrimaryDark">#263238</color>
    <color name="classic_darkTheme_colorAccent">#90a4ae</color>
    <color name="classic_darkTheme_colorBackground">#303030</color>
    <color name="classic_darkTheme_colorTintedBackground">#263238</color>

的build.gradle:

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    useLibrary 'org.apache.http.legacy'

    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }


    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    defaultConfig {
        applicationId "com.example.*********"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    lintOptions {
        checkReleaseBuilds true
        abortOnError false
        xmlReport true
        htmlReport true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            lintOptions {
                disable 'MissingTranslation'
            }
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile('com.android.support:appcompat-v7:24.2.0') {
        force = true;
    }
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //compile 'com.survivingwithandroid:weatherlib:1.4.0'
    //compile 'com.survivingwithandroid:weatherlib_volleyclient:1.4.0'
    compile files('libs/CircleImageView-master/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar')
    //compile 'com.google.firebase:firebase-analytics:9.4.0'

    compile 'com.google.android.gms:play-services-maps:10.2.0'
    compile 'com.scottyab:aescrypt:0.0.1'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-messaging:10.2.0'
    compile 'com.google.firebase:firebase-crash:10.2.0'
    compile 'com.google.firebase:firebase-storage:10.2.0'
    compile 'com.firebaseui:firebase-ui:1.2.0'
    compile 'com.google.firebase:firebase-ads:10.2.0'
    compile 'com.android.support:multidex:0.6.0'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.google.android.apps.dashclock:dashclock-api:+'
    compile 'com.roughike:bottom-bar:1.4.0.1'
    compile 'com.diogobernardino:williamchart:2.2'
    compile 'com.github.markushi:circlebutton:1.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.google.android.gms:play-services-gcm:10.2.0'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bumptech.glide:glide:3.5.2'

    //compile 'com.google.android.gms:play-services-appindexing:10.2.0'
}
apply plugin: 'com.google.gms.google-services'

编辑;我试着改变

<item name="colorBackground">@color/darkTheme_colorBackground</item>

<item name="android:colorBackground">@color/darkTheme_colorBackground</item>

这解决了所有的colorbackground错误。但不是colortintedbackground错误。

1 个答案:

答案 0 :(得分:0)

我首先将build.gradle更新为最新版本,就像您拥有依赖项一样。这些都是过时的。

 compileSdkversion 23
 buildToolsVersion "23.0.0"