Java android-support-v7-appcompat 库项目不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19841657/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 20:37:24  来源:igfitidea点击:

android-support-v7-appcompat library project won't work

javaandroideclipseandroid-support-librarybuildpath

提问by pawelo

I am trying to add Support Library v7 to my clean android project as support library (with resources). I followed every instruction here: http://developer.android.com/tools/support-library/setup.html#downloadand android.support.v7.* package is not visible in my main project.

我正在尝试将支持库 v7 添加到我干净的 android 项目中作为支持库(带有资源)。我遵循了这里的每一条指令:http: //developer.android.com/tools/support-library/setup.html#download和 android.support.v7.* 包在我的主项目中不可见。

Here is library reference in main project:

这是主项目中的库参考:

Library reference in main project

主项目中的库参考

Support library project tree:

支持库项目树:

library project tree

图书馆项目树

Support library project build path: library prject build path

支持库项目构建路径: 库项目构建路径

And finally, my main project tree

最后,我的主要项目树

main project tree

主项目树

I don't see any errors in Problems tab, app compiles and runs normally but i cannot import android.support.v7 package which apparently isn't in build path in main project. I went through instruction twice in clean projects/workspace. I cleaned project, restarted Eclipse and nothing... All resources from library project are unreachable too.

我在问题选项卡中没有看到任何错误,应用程序编译并正常运行,但我无法导入 android.support.v7 包,该包显然不在主项目的构建路径中。我在干净的项目/工作区中接受了两次指导。我清理了项目,重新启动了 Eclipse,什么也没有......库项目中的所有资源也无法访问。

Thanks in advance :)

提前致谢 :)

采纳答案by Raghunandan

Copy the library project to the folder where your android project is.

将库项目复制到你的android项目所在的文件夹中。

Select File > Import.

选择文件 > 导入。

Select Existing Android Code Into Workspace and click Next.

选择 Existing Android Code Into Workspace 并单击 Next。

Browse and import the same to eclipse

浏览并导入相同的 eclipse

Once the library project is imported you can refer the same in your android project.

导入库项目后,您可以在您的 android 项目中引用相同的内容。

This is similar to setting up google play services in eclipse described here. Check the 4th step

这类似于在此处描述的 eclipse 中设置 google play 服务。检查第四步

http://developer.android.com/google/play-services/setup.html

http://developer.android.com/google/play-services/setup.html

回答by RightHandedMonkey

It looks like android-support-v7-appcompat.jaris missing from your libs folder.

它看起来像Android的支持-V7-appcompat.jar从您的libs文件夹丢失。

When you download the Android Support Library through the Android SDK Manager it makes the support .jar files you need available under {SDK Location}\extra\android\support.

当您通过 Android SDK 管理器下载 Android 支持库时,它会在 {SDK Location}\extra\android\support 下提供您需要的支持 .jar 文件。

To use the v7 files, copy these to your project's /libs folder.

要使用 v7 文件,请将它们复制到项目的 /libs 文件夹中。

  • android-support-v4.jar
  • android-support-v7-appcompat.jar
  • android-support-v7-gridlayout.jar (*if needed)
  • android-support-v7-mediarouter.jar (*if needed)
  • android-support-v4.jar
  • android-support-v7-appcompat.jar
  • android-support-v7-gridlayout.jar(*如果需要)
  • android-support-v7-mediarouter.jar(*如果需要)

Typical gotchas (this looks OK in your setup):

典型的问题(这在您的设置中看起来不错):

  • Make sure the min SDK is at least API 7
  • Make sure the project target build is at least API 17
  • 确保最小 SDK 至少为 API 7
  • 确保项目目标构建至少为 API 17

For more information about using the support V7 package (including running the v7 samples) can be found at the RHM Guide to Android Support Lib.

有关使用支持 V7 包(包括运行 v7 示例)的更多信息,可以在RHM Guide to Android Support Lib 中找到

回答by Umesh N

The issue seems to be in Absolute path in case of Windows base machine. I faced the issue of referencing support libraries When I moved Eclipse and related libraries to different drive than where the project was. Copy paste the libraries to folder on same derive in a way that it can pick by relative path. ..\androidCommonlib\appcompat android.library

在 Windows 基础机器的情况下,问题似乎出在绝对路径中。当我将 Eclipse 和相关库移动到与项目所在位置不同的驱动器时,我遇到了引用支持库的问题。以一种可以通过相对路径选择的方式将库复制粘贴到同一派生上的文件夹中。..\androidCommonlib\appcompat android.library