我之前使用Android studio 1.1构建了我的应用程序。那时我没有问题。升级后,当我尝试重建我的应用程序时收到以下错误。
D:\-----\src\main\res\color\common_signin_btn_text_dark.xml
Error:(4, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_pressed').
Error:(5, 85) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_disabled').
Error:(6, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_focused').
Error:(7, 56) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_disabled').
Error:(8, 26) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_dark_text_default').
D:\-------\src\main\res\color\common_signin_btn_text_light.xml
Error:(4, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_pressed').
Error:(5, 85) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_disabled').
Error:(6, 55) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_focused').
Error:(7, 56) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_disabled').
Error:(8, 26) No resource found that matches the given name (at 'color' with value '@color/common_signin_btn_light_text_default').
Error:Execution failed for task ':colorBookPro:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\Admin\AppData\Local\Android\sdk1\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
我试图搜索解决方案但找不到任何解决方案。这是我的build.gradle文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.demo"
minSdkVersion 10
targetSdkVersion 18
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile project(':main')
compile project(':library')
compile 'com.google.android.gms:play-services:8.3.0'
compile files('libs/StartAppInApp-2.4.7.jar')
}
这些文件位于res / color文件夹中。 click here for image 我还尝试使用API 23和构建工具23.0.1以及许多其他选项。我似乎不理解这个问题,因为它第一次不存在。 我在2个月前制作了应用程序。我是编码新手,所以如果我写了什么傻话,请耐心等待。我希望有一个人可以帮助我。
提前致谢。
答案 0 :(得分:2)
在 color.xml 中,您可以按如下方式定义颜色:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="blue" type="color">#FF33B5E5</item>
<item name="purple" type="color">#FFAA66CC</item>
<item name="green" type="color">#FF99CC00</item>
<item name="orange" type="color">#FFFFBB33</item>
<item name="red" type="color">#FFFF4444</item>
<item name="darkblue" type="color">#FF0099CC</item>
<item name="darkpurple" type="color">#FF9933CC</item>
<item name="darkgreen" type="color">#FF669900</item>
<item name="darkorange" type="color">#FFFF8800</item>
<item name="darkred" type="color">#FFCC0000</item>
<integer-array name="androidcolors">
<item>@color/blue</item>
<item>@color/purple</item>
<item>@color/green</item>
<item>@color/orange</item>
<item>@color/red</item>
<item>@color/darkblue</item>
<item>@color/darkpurple</item>
<item>@color/darkgreen</item>
<item>@color/darkorange</item>
<item>@color/darkred</item>
</integer-array>
答案 1 :(得分:1)
这是因为您使用了referrer
文件中未包含的颜色。
在两个颜色文件中添加颜色名称和值,如下所示。
color.xml
答案 2 :(得分:1)
感谢所有人的建议,但不幸的是,他们都没有工作。我终于通过用
替换common_signin_button_text_light.xml中的颜色源来解决错误<item android:state_pressed="true" android:color="@color/common_google_signin_btn_text_light_pressed" />
<item android:state_focused="true" android:state_enabled="false" android:color="@color/common_google_signin_btn_text_light_disabled" />
<item android:state_focused="true" android:color="@color/common_google_signin_btn_text_light_focused" />
<item android:state_enabled="false" android:color="@color/common_google_signin_btn_text_light_disabled" />
<item android:color="@color/common_google_signin_btn_text_light_default" />
和common_signin_button_text_dark.xml
<item android:state_pressed="true" android:color="@color/common_google_signin_btn_text_dark_pressed" />
<item android:state_focused="true" android:state_enabled="false" android:color="@color/common_google_signin_btn_text_dark_disabled" />
<item android:state_focused="true" android:color="@color/common_google_signin_btn_text_dark_focused" />
<item android:state_enabled="false" android:color="@color/common_google_signin_btn_text_dark_disabled" />
<item android:color="@color/common_google_signin_btn_text_dark_default" />
更新Android Studio后似乎更新了资源文件。
在进行了上述更改后,我能够成功构建我的应用。
答案 3 :(得分:0)
In color.xml you should declare color:-
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="common_singin_btn_light_text_pressed">#0288D1</color>
</resources>
答案 4 :(得分:0)
转到src \ main \ res \ layout文件夹结构。
在XML中,替换字符串:
"android:textColor:@colour/common_google_signin_btn_text_light_focused"
with:
android:textColor="#90000000".
解决了我的问题
答案 5 :(得分:0)