Java Android appcompat v7 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24096416/
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
Android appcompat v7 error
提问by jkally
Being new to Android developent I followed the simplest of tutorials, built a new android project, accepting all default settings (built it for kitkat). To my dismay I have an un-planned project - appcompat_v7
, along with the errors:
作为 Android 开发新手,我遵循了最简单的教程,构建了一个新的 android 项目,接受所有默认设置(为 kitkat 构建)。令我沮丧的是,我有一个计划外的项目 -appcompat_v7
以及错误:
The container 'Android Dependencies' references non existing library 'C:\Users...\workspace\appcompat_v7\bin\appcompat_v7.jar'
容器“Android 依赖项”引用了非现有库“C:\Users...\workspace\appcompat_v7\bin\appcompat_v7.jar”
and twice the following
和以下两次
The project cannot be built until build path errors are resolved
在解决构建路径错误之前无法构建项目
Is there a quick way to fix these? Is this a sign of how difficult, and bugged with unpleasant surprises learning Android is going to be?
有没有快速解决这些问题的方法?这是否表明学习 Android 将会变得多么困难,并且会被令人不快的惊喜所困扰?
(Hope it will not be similar to learning IOS 6 years ago...)
(希望不会像6年前学IOS一样...)
采纳答案by Y.S
The appcompat_v7
library is added by default to an Android project. You will most likely need it for any demo projects you start making.
该appcompat_v7
库默认添加到 Android 项目中。对于您开始制作的任何演示项目,您很可能需要它。
To correctly add this library, follow these steps:
要正确添加此库,请按照下列步骤操作:
For Android Studio:
对于安卓工作室:
1.Ensure that you have the Android Support Repositoryinstalled in your SDK Manager:
1.确保您的SDK Manager 中安装了Android Support Repository:
2.In your build.gradle
file, include the following implementation
statement
2.在您的build.gradle
文件中,包含以下implementation
语句
implementation 'com.android.support:appcompat-v7:+'
within the dependency
bracket.
所述内dependency
支架。
3.Perform a Gradle sync with the Sync Project
button.
3.使用Sync Project
按钮执行 Gradle 同步。
~LEGACY ANSWER~:
〜传统答案〜:
For Eclipse:
对于日食:
The trick is, you need to clean & build the appcompat_v7
project. Go to
诀窍是,您需要清理并构建appcompat_v7
项目。去
Project -> select Clean -> select the project.
After doing this, if the project does not get built automatically, right click on the project in the package explorer and select Build Project
. Now the .jar
file will be generated in the project's bin
folder. After that, clean & build all projects that reference appcompat_v7
.
执行此操作后,如果项目未自动构建,请右键单击包资源管理器中的项目并选择Build Project
。现在该.jar
文件将在项目的bin
文件夹中生成。之后,清理并构建所有引用appcompat_v7
.
Now the library should be correctly referenced by all projects that need it.
现在,所有需要它的项目都应该正确引用该库。
Note also that:
另请注意:
- You must have the latest versions of SDK Tools/ Build Tools/ Platform Tools. If you try this and it doesn't work, then go to the Android SDK Manager and make sure you have the latest versions of the required tools.
- In case your project only requires API level 14 (Ice Cream Sandwich) & above, select API level 14 for "minimum required SDK" in the project wizard when you create a new project. Now the appcompat_v7 library will not be required for this project, and the application will use the native ActionBar class which is present in AOSP builds from ICS onwards.
- 您必须拥有最新版本的SDK 工具/构建工具/平台工具。如果您尝试此操作但它不起作用,请转到 Android SDK 管理器并确保您拥有所需工具的最新版本。
- 如果您的项目只需要 API 级别 14(冰淇淋三明治)及更高级别,请在创建新项目时在项目向导中为“最低要求的 SDK”选择 API 级别 14。现在,此项目不需要 appcompat_v7 库,应用程序将使用本机 ActionBar 类,该类存在于 ICS 以后的 AOSP 构建中。
Further References:
进一步参考:
1.How to add Android Support v7 libraries in eclipse.
1.如何在eclipse中添加Android Support v7库。
2.Android actionbar how to add supporting library v7 appcompat for Eclipse.
2. Android actionbar 如何为Eclipse 添加支持库v7 appcompat。
3.android-support-v7-appcompat library project won't work.
3. android-support-v7-appcompat 库项目不起作用。
4.Difference between android-support-v7-appcompat and android-support-v4.
回答by prabhakaran
Need to update your SDK manager
需要更新您的 SDK 管理器
click ur sdk manager icon in the ecilipse then update android support Repositoryin the extras
单击 ecilipse 中的 sdk 管理器图标,然后在 extras 中更新android support Repository
then
然后
go to File->import->existing project
转到文件->导入->现有项目
abt bundle->sdk->extra->android->support->v7 to workspace
abt bundle->sdk->extra->android->support->v7 到工作区
after import v7 to workspace go to lib folder choose both jar and right click and choose build to workspace then again right click v7 project go to java build path choose the checkbox and click apply and ok..
将 v7 导入到工作区后,转到 lib 文件夹,选择 jar 并右键单击并选择构建到工作区,然后再次右键单击 v7 项目转到 java 构建路径选择复选框并单击应用并确定。
if u have updated sdk then follow this steps
如果您已更新 sdk,请按照以下步骤操作
step 1:
第1步:
Right click ur project then go to
右键单击您的项目,然后转到
property->choose java build path
属性->选择java构建路径
step 2:
第2步:
click Add External jar
单击添加外部 jar
Step 3:
第 3 步:
Browse to ur adt bundle go to ur workspace choose the folder
浏览到你的 adt 包去你的工作区选择文件夹
android-support-v7-appcompat -> lib -> appcompat_v7.jar
android-support-v7-appcompat -> lib -> appcompat_v7.jar
回答by CyberSpy_zero
I had the same problem and I tried all of mentionded above advices and much more from, but no one helped me to solve my issue. My solution was creating a progect with minimum required SDK API 14: Android 4.0 (IceCreamSandwich). Doing this way Eclipse will not create appcompat_v7 project.
我遇到了同样的问题,我尝试了上面提到的所有建议以及更多建议,但没有人帮助我解决我的问题。我的解决方案是使用最低要求的 SDK API 14: Android 4.0 (IceCreamSandwich)创建一个项目。这样做 Eclipse 不会创建 appcompat_v7 项目。
Also I found another, better, solution:
我还找到了另一个更好的解决方案:
- Go to Android SDK Managerand install Android 5.0.1 (API 21)or newer. If you don't use the emulator you can install only SDK Platformand Google APIs;
- Go to appcompat_v7-> Properties-> Androidand check Android 5.0.1in the Project Build Target;
- Then go to Java Build Path-> Order and Exportand check Android 5.0.1;
- Do the same procedure for your project.
- 转到Android SDK Manager并安装Android 5.0.1 (API 21)或更新版本。如果不使用模拟器,则只能安装SDK Platform和Google APIs;
- 转到appcompat_v7-> Properties-> Android并在Project Build Target 中检查Android 5.0.1;
- 然后转到Java Build Path-> Order and Export并检查Android 5.0.1;
- 对您的项目执行相同的过程。
回答by BK Manly
Appcompat_7 error solved!
Appcompat_7 错误已解决!
Hi, im a complete beginner, i solved my problem by go to SDK manager update/install all the new android sdk build tools(as im not sure which is which i should update/install so i update/install all the build tools. after updated/installed all the new build tools i closed my eclipse and relaunch the eclipse again. if you see any error again? go to the top bar click PROJECTand choose CLEAN. and run your application again and i think it will work fine..
嗨,我是一个完整的初学者,我通过转到 SDK 管理器更新/安装所有新的android sdk 构建工具解决了我的问题(因为我不确定我应该更新/安装哪个,所以我更新/安装所有构建工具。之后更新/安装了所有新的构建工具 我关闭了我的 eclipse 并再次重新启动了 eclipse。如果你再次看到任何错误?转到顶部栏单击PROJECT并选择CLEAN。然后再次运行你的应用程序,我认为它会正常工作..
回答by Don 3000
The accepted answer worked for me but only after I'd installed the latest Java JDK (which was a solution to the problem detailed here Android - "Parsing Data for android-21 failed")
接受的答案对我有用,但只有在我安装了最新的 Java JDK 之后(这是Android 中详述的问题的解决方案- “Android-21 的数据解析失败”)
回答by Yassine BELDI
it worked for me when i changed project build tarjet to API 21 for the android_support_v7_appcompact project
当我将 android_support_v7_appcompact 项目的项目构建 tarjet 更改为 API 21 时,它对我有用
回答by GraSim
Strange fix but this worked for me ( My minimum SDK for my project is 10 - can't use 14)
奇怪的修复,但这对我有用(我的项目的最低 SDK 是 10 - 不能使用 14)
- Right-click on the "appcompat_v7" project and go to -> Properties -> Android.
- Your target build should already be set at the latest build (in my case Android 5.0.1). Click any other android package (apart from its current target) and click "Apply". Click "Ok" to close the box.
- Re-open the Properties box by the same method but this time check the latest build (in my case Android 5.0.1) as the Project Build Target. Click "Apply", then "Ok" to close the box.
- Clean the appcompat_v7 project. You'll probably need to clean/build all other projects that reference this library.
- 右键单击“appcompat_v7”项目并转到 -> 属性 -> Android。
- 您的目标版本应该已经设置为最新版本(在我的例子中是 Android 5.0.1)。单击任何其他 android 包(除了其当前目标),然后单击“应用”。单击“确定”关闭该框。
- 通过相同的方法重新打开属性框,但这次检查最新版本(在我的情况下为 Android 5.0.1)作为项目构建目标。单击“应用”,然后单击“确定”关闭该框。
- 清理 appcompat_v7 项目。您可能需要清理/构建引用此库的所有其他项目。
This solved it for me.
这为我解决了它。
回答by Sachindra N. Pandey
I was having with same Issue and fed up but finally I got the answer . I resolved this by Copy appcompat library E:\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat and paste appcompat Library in the the Project which I want to Import . I close the Eclipse and reopen. But One thing I want to consider before these stuff I updated Android Support Repository and Android Support Library as well.
我遇到了同样的问题并且受够了,但最终我得到了答案。我通过 Copy appcompat library E:\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\appcompat 解决了这个问题,并将 appcompat Library 粘贴到我想要导入的项目中。我关闭 Eclipse 并重新打开。但是在这些东西之前我想考虑的一件事我还更新了 Android Support Repository 和 Android Support Library。
回答by phil294
I solved it by downloading the file manually somewhere on the internet (be careful) and putting it into the needed \appcompat_v7\bin\
folder beforecreating a new Android project. After that, also my R.java
file was generated successfully.
我通过在互联网上的某个地方手动下载文件(小心)并将其放入所需的\appcompat_v7\bin\
文件夹中来解决它,然后再创建一个新的 Android 项目。之后,我的R.java
文件也成功生成。
Honestly, no other way seemed to fix it. Could not obtain the file via the SDK manager.
老实说,似乎没有其他方法可以解决它。无法通过 SDK 管理器获取文件。