我在更新到最新的支持库版本26.0.0 (https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0):

错误:(18,21)没有找到与给定名称匹配的资源:attr “android: keyboardNavigationCluster”。

/.../app/build/intermediates/res/merged/beta/debug/values-v26/values-v26.xml
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:(18, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
Error:Execution failed for task ':app:processBetaDebugResources'.

process. processexception: Failed to execute aapt

该文件来自支持库:

<style name="Base.V26.Widget.AppCompat.Toolbar" parent="Base.V7.Widget.AppCompat.Toolbar">
    <item name="android:touchscreenBlocksFocus">true</item>
    <item name="android:keyboardNavigationCluster">true</item>
</style>

我们正在使用以下版本:

ext.COMPILE_SDK_VERSION = 26
ext.BUILD_TOOLS_VERSION = "26.0.1"

ext.MIN_SDK_VERSION = 17
ext.TARGET_SDK_VERSION = 26
ext.ANDROID_SUPPORT_LIBRARY_VERSION = "26.0.0"
ext.GOOGLE_PLAY_SERVICES_LIBRARY_VERSION = "11.0.2"

compile 'com.android.support:appcompat-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:design:' + ANDROID_SUPPORT_LIBRARY_VERSION
compile 'com.android.support:recyclerview-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION

什么好主意吗?


当前回答

我通过在构建中做一些更改来解决这个问题。gradle文件

根构建的更改。Gradle如下:

subprojects {
   afterEvaluate { 
     project -> if (project.hasProperty("android")) { 
       android { 
        compileSdkVersion 26 
        buildToolsVersion '26.0.1' 
       } 
      }
    } 
}

构建的变化。Gradle如下:

compileSdkVersion 26 
buildToolsVersion "26.0.1"

and

dependencies {
    compile 'com.android.support:appcompat-v7:26.0.1'
}

其他回答

//Adding this to the root build.gradle solved my problem, thanks @Yalamber
subprojects {
        afterEvaluate { project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion 26
                    buildToolsVersion '26.0.2'
                }
            }
        }
    }

我的一个PhoneGap项目(Android studio 3.0.1)也面临着同样的问题。为了解决这个问题,我采取了以下步骤

1)右键单击项目名称(在我的例子中是android),选择“打开模块设置”

2)选择模块(android和CordovaLib)

3)单击顶部的属性

4)选择编译SDK版本(我选择API 26: Android 8.0)

5)选择构建工具版本(我选择了26.0.2)

6)源兼容性(1.6)

7)目标兼容性(1.6)

单击Ok并重新构建项目。

下面的链接显示了我所遵循的步骤的设置

https://app.box.com/s/o11xc8dy0c2c7elsaoppa0kwe1d94ogh https://app.box.com/s/ofdcg0a8n0zalumvpyju58he402ag1th

我不得不改变compileSdkVersion = 26和buildToolsVersion = '26.0.1'在我所有的依赖构建。gradle文件

我能够解决它通过更新sdk版本和工具在gradle compileSdkVersion 26 buildToolsVersion“26.0.1”

并支持库26.0.1 https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-1

我有这个确切的错误,我意识到我的compileSdkVersion设置为25,我的buildToolsVersion设置为“26.0.1”。

所以我只是把compileSdkVersion改为26并同步了Gradle。这为我解决了问题。

编辑:我的targetSDKVersion也被设置为26