错误:找不到资源android:attr / colorError

问题描述 投票:0回答:1

将我的compileSdkVersion,TargetSdkVersion和库版本升级到28.我的项目将不再构建。我目前专门为'mFlavor'打造,所以请忽略其他风味。 Manaul命令gradlew assembleMFlavorDebug

这是我的build.gradle(项目级别)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        mavenCentral()
        maven {url 'https://maven.fabric.io/public'}
        jcenter()
    }



    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        /*classpath 'com.google.gms:google-services:3.1.1'*/
        classpath 'com.google.gms:google-services:4.2.0'
        // classpath 'com.google.gms:google-services:2.0.0-alpha3'

        classpath 'io.fabric.tools:gradle:1.25.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "https://maven.google.com"}
        maven{url "https://jitpack.io"}
        google()
        jcenter()
    }
}

这是我的build.gradle(应用程序级别)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories{
    maven {url 'https://maven.fabric.io/public'}
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file('keystore.properties')

// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()

// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    flavorDimensions "default"

    buildToolsVersion '28.0.3'
    compileSdkVersion 28
    defaultConfig {

        targetSdkVersion 27


        versionCode 19
        versionName "1.0"

        // If you have different applicationIds for buildTypes or productFlavors uncomment this block.
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["resourcePackageName": android.defaultConfig.applicationId]
            }
        }

        vectorDrawables.useSupportLibrary = true
        /*resConfigs "en", "ar"*/
    }
    buildTypes {
        release {
            // remove unused resources
            shrinkResources true
            // remove unused code
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable false
            jniDebuggable false
            //signingConfig signingConfigs.config
            renderscriptDebuggable false
            zipAlignEnabled true
        }
        debug {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        //checkReleaseBuilds false
        disable 'MissingTranslation'
        disable 'ExtraTranslation'

    }
    /*aaptOptions{
        cruncherEnabled = false
    }*/
    productFlavors {
        tFLavor {
            compileSdkVersion 22
            applicationId "com.tyu"
            versionName "1.0.0"
            versionCode 20

        }
        oFlavor {
            compileSdkVersion 22
            applicationId "com.op"
            versionName = "1.2.0"
        }

        mFlavor {
            minSdkVersion 16
            compileSdkVersion 28
            targetSdkVersion 28
            applicationId "pk.com.mnb"
            versionName = "4.0.2"
            versionCode = 55

        }

        wFlavor {
            minSdkVersion 14
            compileSdkVersion 22
            applicationId "com.wer"
            versionName = "1.0"
            versionCode = 1
        }
        uFlavor {
            compileSdkVersion 22
            applicationId "com.uio"
            versionName = "1.0"
        }
        zFlavor {
            minSdkVersion 14
            compileSdkVersion 26
            targetSdkVersion 26
            applicationId "com.abc"
            versionName = "1.0.2"
            versionCode = 4


        }

        motoFlavor {
            minSdkVersion 14
            compileSdkVersion 25
            targetSdkVersion 25
            applicationId "pk.com.xyz"
            versionName = "2.2.2"
            versionCode = 26


        }
    }
    //compileSdkVersion 27
}

repositories{
    mavenCentral()
    mavenLocal()
    flatDir{
        dirs '/src/mnb/libs', '/src/zxc/libs'
    }
}

//def AAVersion = "4.4.0"
def AAVersion = "4.5.2"
dependencies {
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    implementation "org.androidannotations:androidannotations-api:$AAVersion"
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    // compile 'com.android.support:cardview-v7:23.1.1'
    implementation 'com.android.support:support-v13:28.0.0'
    /*implementation 'com.intuit.sdp:sdp-android:1.0.6'*/
    implementation 'com.google.code.gson:gson:2.8.0'
    // implementation 'com.google.code.gson:gson:2.8.0'
    // compile files('libs/activeandroid-3.1-beta.jar')
    implementation 'com.google.android.gms:play-services-maps:16.1.0'
    implementation 'com.google.android.gms:play-services-gcm:16.1.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    /*   implementation 'com.google.android.gms:play-services-analytics:11.0.0'*/
    //implementation 'com.android.support:multidex:1.0.1'
    /*compile 'com.google.zxing:core:3.0.1'*/
    /* compile files('libs/android-core-3.2.1.jar')
                                                    compile files('libs/core-3.2.1.jar') */
    implementation 'net.hockeyapp.android:HockeySDK:5.1.0'

    implementation 'com.facebook.android:facebook-android-sdk:4.6.0'

    implementation('com.github.chrisbanes:PhotoView:1.3.0') {
        exclude module: 'support-v4'
    }
    //mobilinkCompile 'com.facebook.android:facebook-android-sdk:4.14.0@aar'
    uFlavorImplementation('com.twitter.sdk.android:twitter:2.2.0@aar') {
        transitive = true
        exclude module: 'support-v4'
    }
    implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
    implementation 'com.google.firebase:firebase-core:16.0.8'
}

apply plugin: 'com.google.gms.google-services'

这是我的gradle构建错误日志

E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v26\values-v26.xml:7: error: resource android:attr/colorError not found.
  E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v26\values-v26.xml:11: error: resource android:attr/colorError not found.
  E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v26\values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
  E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  E:\Personal\ProjectName\app\build\intermediates\incremental\mergeFlavorNameDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\design-28.0.0.aar\51e52ea0f459299746be071f693e7a44\res\values\values.xml: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/keyboardNavigationCluster not found.

  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/fontStyle not found.

  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/font not found.

  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/fontWeight not found.

  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/fontVariationSettings not found.

  C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\9f002bd341f5fe5ec616948fde22969d\res\values\values.xml: AAPT: error: resource android:attr/ttcIndex not found.

  error: failed linking references.
  Command: C:\Users\UserName\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\6d9ed65b6dd5edf0927b82048b67f6e3\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
          D:\AndroidSDK\platforms\android-25\android.jar\
          --manifest\
          E:\Personal\ProjectName\app\build\intermediates\merged_manifests\FlavorNameDebug\processFlavorNameDebugManifest\merged\AndroidManifest.xml\
          -o\
          E:\Personal\ProjectName\app\build\intermediates\processed_res\FlavorNameDebug\processFlavorNameDebugResources\out\resources-FlavorNameDebug.ap_\
          -R\
          @E:\Personal\ProjectName\app\build\intermediates\incremental\processFlavorNameDebugResources\resources-list-for-resources-FlavorNameDebug.ap_.txt\
          --auto-add-overlay\
          --java\
          E:\Personal\ProjectName\app\build\generated\not_namespaced_r_class_sources\FlavorNameDebug\processFlavorNameDebugResources\r\
          --custom-package\
          com.ooredoo.ProjectName\
          -0\
          apk\
          --output-text-symbols\
          E:\Personal\ProjectName\app\build\intermediates\symbols\FlavorName\debug\R.txt\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
android gradle android-gradle
1个回答
1
投票

您的编译SDK版本为25,但是您(或您依赖的库)使用仅在API 28中添加的资源。更新您的build.gradle文件以使用最新的编译SDK版本:

android {
    compileSdkVersion 28
    ...
}
© www.soinside.com 2019 - 2024. All rights reserved.