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

什么好主意吗?


当前回答

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

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

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

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

其他回答

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

在更新你的android studio到3.0后,如果出现这个错误,只需更新gradle属性,这些是解决我的问题的设置:

compileSdkVersion 26

targetSdkVersion 26

buildToolsVersion '26.0.2'

对于任何使用nativescript并面临此问题的人:您可以添加

compileSdkVersion 26
buildToolsVersion '26.0.1'

在App_Resources / Android应用程序。Gradle(在android{下)

然后运行tns平台删除android和tns构建android在你的项目根。

我对离子也有同样的问题。

cordova platform remove android
cordova platform add android@6.4.0

在platform/android/ project .properties中替换

cordova.system.library.1=com.android.support:support-v4+

To

cordova.system.library.1=com.android.support:support-v4:26+

我在react-native-youtube和react-native-orientation上也有类似的错误。

搞清楚了,那就是建造。这些项目的gradle使用compileSdkVersion 23,但Feature: android:keyboardNavigationCluster是从api 26 (android 8)开始添加的。

那么如何修复呢?

一个简单的解决方法是编辑你的/android/build。Gradle (!!不是/android/app/build.gradle),并将这些代码添加到文件底部。

这允许你强制SDK和BuildTool-Version你的子模块使用:

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