我在更新到最新的支持库版本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'
}

其他回答

改变 编译SDK版本:

compileSdkVersion 26

构建工具版本:

buildToolsVersion "26.0.1"

目标SDK版本:

targetSdkVersion 26

依赖关系:

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

内Gradle。

在我的react-native项目中,这个错误是在react-native-fbsdk中生成的。更新react-native-fbsdk/android/build。下面的Gradle修复了这个问题。

compileSdkVersion 26
buildToolsVersion "26.0.1"

我通过在构建中做一些更改来解决这个问题。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'
}

我最近碰到过这个,记得它是怎么来的。这是xamarin和android的不匹配。*版本和已安装的Android SDK版本。

当前VS2017 15.5.3新项目默认为nuGet Xamarin.Android。*为25.4.0.2,用于跨平台开发的默认VS安装是以下Android SDK包:

Android 7.1 -牛轧糖 Android SDK平台25 谷歌APIs Intel x86 Atom系统镜像

如果你升级了你的解决方案nuGet Xamarin.Android。*到26.1.0.1,那么你需要在Android SDK中安装以下软件:

安卓8.0 -奥利奥 Android SDK平台26 谷歌APIs Intel x86 Atom系统镜像

这个问题是由我的一个需要版本26编译的库引起的。

将targetSdkVersion设置为26会导致其他问题,你必须调整应用程序以适应Oreo平台。这并不是所有问题的正确解决方案。

只需要将compileSdkVersion设置为26,将buildToolsVersion设置为26.0.2就可以了。

还应该更新所有支持库以使用26.1.0或更高版本。