简体   繁体   English

找不到与名称匹配的资源-Android Studio

[英]No resource found that matches the name - Android Studio

I just downloaded Android Studio and have created a new project. 我刚刚下载了Android Studio,并创建了一个新项目。

Right off the bat, I'm getting two errors: 马上,我会遇到两个错误:

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

Here is my gradle: 这是我的礼物:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.test.testapp"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
}

and my installed packages: 和我安装的软件包:

在此处输入图片说明 在此处输入图片说明

What is messed up here? 这是怎么了? Thanks 谢谢

In your gradle, compileSdkVersion is 22 while your support library version is 23. The two should match. 顺带一提,compileSdkVersion是22,而支持库版本是23。两者应该匹配。

See Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23 请参阅错误检索父项:在升级到AppCompat v23后找不到与给定名称匹配的资源

I also had same problem now. 我现在也有同样的问题。 I tried below steps and worked perfectly. 我尝试了以下步骤,并完美地工作了。

In .gradle change like this 在.gradle中这样改变

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v13:23.0.1'
}

You'll get error in style file change it as below 您将在样式文件中收到错误,如下所示进行更改

<style name="AppTheme">
    <!-- Customize your theme here. -->
</style>

modify your main_menu.xml 修改您的main_menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
    <item android:id="@+id/action_settings" android:title="@string/action_settings"
        android:orderInCategory="100" android:showAsAction="never" />
</menu>

In MainActivity remove AppCompatActivity like 在MainActivity中删除AppCompatActivity

MainActivity extends Activity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到与给定名称匹配的资源(Android) - No resource found that matches the given name (Android) 找不到与给定名称“ Theme.AppCompat.Light”匹配的资源。 Android Studio - No resource found that matches the given name 'Theme.AppCompat.Light'. Android Studio 找不到与给定名称匹配的资源 - No resource found that matches the given name “找不到与给定名称匹配的资源” - “No resource found that matches the given name” 找不到与给定名称匹配的资源 - No resource found that matches the given name Android 打包问题“错误:错误:找不到与给定名称匹配的资源” - Android Packaging Problem “error: Error: No resource found that matches the given name ” AAPT:找不到与给定名称匹配的资源:attr&#39;android:keyboardNavigationCluster&#39; - AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster' 检索父项时出错:找不到与给定名称android相匹配的资源 - Error retrieving parent for item: No resource found that matches the given name android 找不到与给定名称匹配的资源:attr&#39;android:keyboardNavigationCluster&#39; - No resource found that matches the given name: attr 'android:keyboardNavigationCluster' 找不到与给定名称匹配的资源:attr'colorPrimaryDark' - No resource found that matches the given name: attr 'colorPrimaryDark'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM