Java 更新后android studio中的资源错误:找不到资源
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32092511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
resource error in android studio after update: No Resource Found
提问by James Dobson
After a recent update to Android Studio, we're having problems getting a project to compile that previously worked. At first we were getting the following error:
在最近对 Android Studio 进行更新后,我们在编译以前运行的项目时遇到了问题。起初我们收到以下错误:
/Users/james/Development/AndroidProjects/myapp/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/res/values-v23/values-v23.xml
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'.
I updated the sdk build target in our gradle file to 23, which made this specific issue go away, but it left us with a ton of apache.http package errors (specifically, a ton of apache packages we use for http stuff are now gone in sdk 23).
我将 gradle 文件中的 sdk 构建目标更新为 23,这使得这个特定问题消失了,但它给我们留下了大量 apache.http 包错误(特别是,我们用于 http 内容的大量 apache 包现在消失了在 SDK 23 中)。
What I want to do is solve the strange resource error, but without updating to sdk 23. I don't have the time to re-write our tools library right now to use whatever new implementation of apache http components has been issued. Does anyone have any ideas?
我想要做的是解决奇怪的资源错误,但没有更新到 sdk 23。我现在没有时间重写我们的工具库来使用任何已发布的 apache http 组件的新实现。有没有人有任何想法?
采纳答案by Tunga
Change the appcompat version in your build.gradle file back to 22.2.1 (or whatever you were using before).
将 build.gradle 文件中的 appcompat 版本改回 22.2.1(或您之前使用的任何版本)。
回答by urnish
in your projects build.gradle file... write as below.. i have solved that error by change the appcompat version from v7.23.0.0 to v7.22.2.1..
在你的项目 build.gradle 文件中......写如下......我已经通过将 appcompat 版本从 v7.23.0.0 更改为 v7.22.2.1 解决了这个错误......
dependencies
{
{
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
}
回答by Roberto B.
You need to set compileSdkVersion to 23.
您需要将 compileSdkVersion 设置为 23。
Since API 23 Android removed the deprecated Apache Http packages, so if you use them for server requests, you'll need to add useLibrary 'org.apache.http.legacy'
to build.gradle as stated in thislink:
由于 API 23 Android 删除了已弃用的 Apache Http 包,因此如果您将它们用于服务器请求,则需要useLibrary 'org.apache.http.legacy'
按照此链接中的说明添加到 build.gradle :
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
...
//only if you use Apache packages
useLibrary 'org.apache.http.legacy'
}
回答by Sanderson
It's works just when the build.grade was changed to that:
仅当 build.grade 更改为以下内容时才有效:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "blablabla"
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:22.0.0'
}
回答by Dinesh Sunny
you should change your compiledsdkversion and targetversion to 23 in the build gradle file specific to the app.Make sure you installed sdk 23, version 6.0 before this.You can watch this vid for more help.https://www.youtube.com/watch?v=pw4jKsOU7go
您应该在特定于该应用程序的构建 gradle 文件中将编译后的 sdkversion 和 targetversion 更改为 23。确保在此之前安装了 sdk 23,版本 6.0。您可以观看此视频以获取更多帮助。https://www.youtube.com/watch?v=pw4jKsOU7go
回答by Arun Alo Chakraborty
I noticed I didn't have sdk 23 installed. So I first installed it then re-built my project. And it worked fine. Also compilesdkVersion should be 23
我注意到我没有安装 sdk 23。所以我首先安装了它,然后重新构建了我的项目。它工作得很好。compilesdkVersion 也应该是 23
回答by Adnan Bal
First of all,
首先,
Try to check your SDK folder, for me, it was mydocuments/appdata/sdk.... etc. So basically my sdk folder was not fully downloaded, the source of this problem mainly. You have to either use another fully downloaded android sdk(including Tools section and extras that you really need) or use the eclipse sdk that you may downloaded earlier for your Eclipse android developments. Then build->clean your project once again.
试着检查你的sdk文件夹,对我来说,是mydocuments/appdata/sdk....等。所以基本上我的sdk文件夹没有完全下载,主要是这个问题的根源。您必须使用另一个完全下载的 android sdk(包括工具部分和您真正需要的附加功能)或使用您之前可能为 Eclipse android 开发下载的 eclipse sdk。然后再次构建-> 清理您的项目。
Worth to try.
值得一试。
回答by diesistdername
Attention, wrong answer coming! But anyone without apache libraries or so might find
注意,错误答案来了!但是任何没有 apache 库的人都可能会发现
compileSdkVersion 23
buildToolsVersion "23.0.0"
//...
dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
}
helpful, it did the trick for me.
很有帮助,它对我有用。
回答by xsushil
if u are getting errors even after downloading newest SDK and Android Studio I am a newbie: What i did was 1. Download the recent SDK (i was ) 2.Open file-Project structure (ctrl+alt+shift+S) 3. In modules select app 4.In properties tab..change compile sdk version to api 23 Android 6.0 marshmallow(latest)
如果您在下载最新的 SDK 和 Android Studio 后仍然遇到错误我是新手:我所做的是 1. 下载最近的 SDK(我是) 2.打开文件项目结构(ctrl+alt+shift+S) 3.在模块中选择应用程序 4.在属性选项卡中..将编译 sdk 版本更改为 api 23 Android 6.0 marshmallow(latest)
make sure compile adk versionand buildtools are of same version(23)
确保编译 adk 版本和 buildtools 是相同的版本 (23)
Hope it helps someone so that he wont suffer like i did for these couple of days.
希望它可以帮助某人,这样他就不会像我这几天那样受苦。
回答by cwiesner
compileSDK should match appCompat version. TargetSDK can still be 22 (e.g. in case you didn't update to the new permission model yet)
compileSDK 应该匹配 appCompat 版本。TargetSDK 仍然可以是 22(例如,如果您还没有更新到新的权限模型)