Programing

com.android.support:recyclerview-v7:26.0.0-beta2 사용시 attr / colorError not found 오류

lottogame 2020. 11. 23. 07:36
반응형

com.android.support:recyclerview-v7:26.0.0-beta2 사용시 attr / colorError not found 오류


Android Studio 3.0 Canary 4를 사용하고 있습니다. 리사이클 러 뷰 라이브러리를 가져 왔습니다. 그런 다음 attr / colorError not found 메시지가 나옵니다. 이것은 app build.gradle입니다.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.robyn.myapplication"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:recyclerview-v7:26.0.0-beta2'
    implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
}

두 라이브러리 구현 'com.android.support:recyclerview-v7:26.0.0-beta2'및 구현 'com.android.support:appcompat-v7:26.0.0-beta2'를 추가 할 때마다이 오류 메시지가 나타납니다. : 여기에 이미지 설명 입력

나는 깨끗하고 재 구축을 시도했지만 오류 메시지가 여전히 있습니다. res / values ​​/ colors를 확인했는데 색상 값이 있습니다. 이 색상 오류가 발생하는 이유는 무엇입니까? 리사이클 러보기를 사용하려면 어떤 버전의 라이브러리를 가져와야합니까?


다음 세부 정보를 변경하면 정상적으로 작동합니다.

compileSdkVersion 26
buildToolsVersion "26.0.0-beta2"

또한 업그레이드 compileSDKVersion하고 buildToolsVersion26 (25였습니다)으로 문제가 해결되었습니다.

compileSdkVersion 26
buildToolsVersion '26.0.2'
...
dependencies {
    ...
    compile 'com.android.support:appcompat-v7:26.0.2'

}

일반적으로 모든 버전을 일관되게 유지해야합니다 (컴파일, 빌드, appcompat 라이브러리).

이는 런타임에서 컴파일 및 안정성을 보장하기위한 것입니다 (lint가 다른 지원 라이브러리 버전을 찾은 경우 후자에 대한 lint 경고도 볼 수 있음).


고침 26.0.0 Beta 2

26.0.0-beta2는 시험판 버전입니다. API 표면은 변경 될 수 있으며 지원 라이브러리의 최신 안정 버전의 기능이나 버그 수정을 반드시 포함하지는 않습니다.

문제에 대해 "26.0.0-beta2"를 사용할 수 있습니다 . Stable Version 을 사용하면 더 좋을 것 입니다.


내 앱이 appcompat-26에 있고 차례로 appcompat-25를 사용하는 Android 라이브러리를 포함하려고 할 때 동일한 오류가 발생했습니다. 내 해결책은 지금까지 앱을 25로 유지하는 것입니다.

I have no idea if it's supposed to be like this. Surely you must be able to publish a library that uses the support lib version X and have it run in apps using support lib version X+1.

I am using AS 3.0-beta7 so maybe it's resolved on stable 3.0 which was released a few days ago.


Just change the minSdk:

e.g.:

android {
   compileSdkVersion 26
   buildToolsVersion "26.0.0-beta2"
   defaultConfig {
      applicationId "com.parse.starter"
      minSdkVersion 15
      targetSdkVersion 21
      versionCode 1
      versionName "1.0"
   }
}

Hope this helps


I found this "attr/colorError" error occurred when I had created product flavours and had put the "legacy" after the "current" in my build.gradle (in "app" folder). When I put the "legacy" before the "current" (as shown below) then the error went away. Maybe the lower "versionCode" or "Sdk" versions need to appear first?

   flavorDimensions "legacycurrent"
   productFlavors {

      legacy {
               dimension "legacycurrent"
               versionCode 98
               minSdkVersion 9
               targetSdkVersion 25
               compileSdkVersion 25
             }
      current {
               dimension "legacycurrent"
               versionCode 99
               minSdkVersion 14
               targetSdkVersion 26
               compileSdkVersion 26
             }
   }

FWW-향후 검색을 위해 루트 build.gradle에 아래 코드를 추가하여 종속성을 검색하고 루트 프로젝트와 일치하도록 수정했습니다. 이것이 잘못된 생각 인 이유와주의 사항이있을 수 있지만 지속적으로 저에게 효과적입니다.

subprojects {
    afterEvaluate {subproject ->
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

Android / build.gradle 하단에 다음 코드를 붙여 넣으면 도움이되었습니다.

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 28
                buildToolsVersion "28.0.3"
            }
        }
    }
}

참고 URL : https://stackoverflow.com/questions/44643943/attr-colorerror-not-found-error-when-using-com-android-supportrecyclerview-v72

반응형