No resource found Errors for support:appcompat-v7:22.0.0 on Android Studio

泄露秘密 提交于 2019-11-30 09:16:20

问题


Am trying to add the Design support Library following this guidelines https://github.com/codepath/android_guides/wiki/Design-Support-Library and i'm having issues.

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

Trying to add this and Its giving me lots of XML errors when building.

Error:(24, 63) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_default_mtrl_alpha').
Error:(25, 93) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_default_mtrl_alpha').
Error:(26, 33) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_textfield_activated_mtrl_alpha').

Error:(20, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_dark').
Error:(21, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_dark').
Error:(20, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_light').
Error:(21, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_light').

Error:(18, 29) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_pressed_holo_light').
Error:(22, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_dark').
Error:(23, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_dark').

Error:(22, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_light').
Error:(23, 118) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_list_selector_disabled_holo_light').
Error:(19, 27) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_btn_rating_star_off_mtrl_alpha').
Error:(21, 27) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_btn_rating_star_off_mtrl_alpha').

Error:(23, 27) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_btn_rating_star_on_mtrl_alpha').
Error:(19, 29) No resource found that matches the given name (at 'drawable' with value '@drawable/abc_btn_switch_to_on_mtrl_00001').

Information:BUILD FAILED

This is the build.gradle below

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.hp.navigationexercise"
        minSdkVersion 21
        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:support-v4:22.2.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-annotations:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
}

回答1:


I got this error when the filename was too long.

If you are running under windows, your build/intermediates/... files can get very long. You will get an odd error like this one if that happens.




回答2:


I solved this by adding multiDexEnabled true in defaultConfig in gradle file.

And by adding

 dexOptions {
        javaMaxHeapSize "4g"
    }

after defaultConfig.




回答3:


Since I ran into the same problem and there is no complete answer, I'll post it.

As @Brian Donovan-Smith mentioned, the problem occurs when one or more file names is too long (more than 260 characters). It is worth to note that the name includes the entire path. So, that was the problem in my case, and I solved it by moving the source folders to a closer to C: location.




回答4:


Make sure you downloaded the files on your computer via SDK manager like in this guide: https://developer.android.com/tools/support-library/setup.html (Scroll down to "Adding libraries with resources")

Gradle alone won't do it, you need to download via SDK manager additoionally as this library inlcudes ressources:

Some Support Libraries contain resources beyond compiled code classes, such as images or XML files. For example, the v7 appcompat and v7 gridlayout libraries include resources.



来源:https://stackoverflow.com/questions/30943180/no-resource-found-errors-for-supportappcompat-v722-0-0-on-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!