包 android.support.v4.app 不存在;在 Android Studio 0.8 中 [英] package android.support.v4.app does not exist ; in Android studio 0.8

查看:84
本文介绍了包 android.support.v4.app 不存在;在 Android Studio 0.8 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将 android studio IDE 更新到 0.8,以便与新的 android L SDK 配合使用.首先,我导入了一个已完成的 android 项目,该项目在旧版本的 android studio 中没有收到任何错误.在 0.8 版中,我行如

I've recently updated the android studio IDE to 0.8 to work with the new android L SDK. To start I imported a finished android project that receives no errors in the older version of android studio. In version 0.8 i lines such as

import android.support.v4.app.Fragment;
get:无法解决支持导致其余代码出错.logcat 返回 101 个

import android.support.v4.app.Fragment;
get: Support cannot be resolved causing the rest of the code to have errors. The logcat returns 101 instances of

Error:(8, 30) error: package android.support.v4.app does not exist

每次我在导入语句中调用支持库时为 1.

1 for each time I call the support library in an import statement.

我试过了

  • 重新安装 IDE
  • 删除idea文件夹的内容
  • 重新安装所有 SDK - 包括支持库
  • 同步gradle
  • 手动将支持库复制到 libs 文件夹中
  • 重建项目
  • 以及创建一个新项目来测试库

不完全确定还剩下什么.

not entirely sure what's left to do.

推荐答案

[由于某些原因,这个答案与 Eclipse 相关,而不是 Android Studio!]

您是否尝试将支持库设置为您的类路径?此链接来自 Android 开发人员网站,提供了一些有关如何执行此操作的信息.

Have you tried setting the support libraries to your class path? This link from the Android Developer's website has some info on how to do that.

尝试按照网站上的以下步骤操作:

Try following these steps from the website:

根据支持库代码创建一个库项目:

Create a library project based on the support library code:

  • 确保您已使用 SDK 管理器下载了 Android 支持库.
  • 创建一个库项目并确保所需的 JAR 文件包含在项目的构建路径中:

  • Make sure you have downloaded the Android Support Library using the SDK Manager.
  • Create a library project and ensure the required JAR files are included in the project's build path:

  • 选择文件 > 导入.
  • 选择 E现有 Android 代码进入工作区,然后点击下一步.
  • 浏览到 SDK 安装目录,然后浏览到 Support Library 文件夹.例如,如果您要添加 appcompat 项目,请浏览至/extras/android/support/v7/appcompat/.
  • 单击完成以导入项目.对于 v7 appcompat 项目,您现在应该会看到一个名为 android-support-v7-appcompat 的新项目.
  • 在新的库项目中,展开 libs/ 文件夹,右键单击每个 .jar 文件并选择构建路径 > 添加到构建路径.例如,在创建 v7 appcompat 项目时,将 android-support-v4.jar 和 android-support-v7-appcompat.jar 文件添加到构建路径中.
  • 右键单击库项目文件夹,然后选择构建路径 > 配置构建路径.
  • 订购和导出选项卡中,检查您刚刚添加到构建路径的 .jar 文件,以便它们可用于依赖于该库项目的项目.例如,appcompat 项目要求您同时导出 android-support-v4.jar 和 android-support-v7-appcompat.jar 文件.
  • 取消选中Android 依赖项.
  • 单击确定"完成更改.
  • Select File > Import.
  • Select Existing Android Code Into Workspace and click Next.
  • Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to /extras/android/support/v7/appcompat/.
  • Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
  • In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
  • Right-click the library project folder and select Build Path > Configure Build Path.
  • In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
  • Uncheck Android Dependencies.
  • Click OK to complete the changes.

您现在为所选的支持库拥有了一个库项目,您可以将其用于一个或多个应用程序项目.

You now have a library project for your selected Support Library that you can use with one or more application projects.

  • 将库添加到您的应用程序项目:
  • 项目资源管理器中,右键单击您的项目并选择属性.
  • 在对话框左侧的类别面板中,选择 Android.
  • 窗格中,点击添加按钮.
  • 选择库项目并单击确定.例如,appcompat 项目应列为 android-support-v7-appcompat.
  • 在属性窗口中,单击确定".
  • Add the library to your application project:
  • In the Project Explorer, right-click your project and select Properties.
  • In the category panel on the left side of the dialog, select Android.
  • In the Library pane, click the Add button.
  • Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
  • In the properties window, click OK.

这篇关于包 android.support.v4.app 不存在;在 Android Studio 0.8 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆