我尝试按照此指南https://github.com/codepath/android_guides/wiki/Design-Support-Library添加设计支持库,但我遇到了问题。
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
}
尝试添加此内容并在构建时给出了很多XML错误。
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
这是
下面的build.gradleapply 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'
}
答案 0 :(得分:11)
当文件名太长时,我收到此错误。
如果您在Windows下运行,您的构建/中间件/ ...文件可能会变得很长。如果发生这种情况,你会得到像这样的奇怪错误。
答案 1 :(得分:2)
我通过在gradle文件中的multiDexEnabled true
中添加defaultConfig
解决了这个问题。
并添加
dexOptions {
javaMaxHeapSize "4g"
}
在defaultConfig
之后。
答案 2 :(得分:1)
由于我遇到了同样的问题并且没有完整的答案,我会发布它。
正如@Brian Donovan-Smith所提到的,当一个或多个文件名太长(超过260个字符)时会出现问题。值得注意的是,该名称包含整个路径。所以,这就是我的问题,我通过将源文件夹移动到更靠近C:位置来解决它。
答案 3 :(得分:0)
请确保您通过SDK管理器下载了计算机上的文件,如本指南所示:https://developer.android.com/tools/support-library/setup.html (向下滚动到“使用资源添加库”)
Gradle单独不会这样做,你需要通过SDK管理器下载,因为这个库包含了资源:
某些支持库包含已编译代码类之外的资源,例如图像或XML文件。例如,v7 appcompat和v7 gridlayout库包含资源。