Android Studio 项目无法解析 ActionBarSherlock 导入 [英] Android Studio project can't resolve ActionBarSherlock imports

查看:28
本文介绍了Android Studio 项目无法解析 ActionBarSherlock 导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Android Studio 项目,它依赖于 build.gradle 中设置的 ActionBarSherlock:

I have an Android Studio project which has a dependency on ActionBarSherlock set in build.gradle:

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile project(':Core')
    compile fileTree(dir: 'libs', include: '*.jar')
}

该项目在命令行上使用 gradle assemble assembleDebug 成功构建,并且当我按下 ctrl+D.但是,当我在 IDE 中查看一些与 Sherlock 相关的源文件时,该文件充满了红色错误通知,从这一行开始:

The project builds successfully on the command line with gradle assemble assembleDebug and also builds and runs just fine from the IDE when I press ctrl+D. When I view some of the Sherlock-related source files in the IDE, though, the file is full of red error notifications, starting with this line:

import com.actionbarsherlock.app.SherlockPreferenceActivity;

弹出的工具提示说

无法解析符号SherlockPreferenceActivity"

Cannot resolve symbol 'SherlockPreferenceActivity'

并且没有任何上下文相关的东西,例如自动完成.

and none of the context-sensitive stuff such as auto-completion is available.

我尝试了 File > Invalidate Caches/Restart > Invalidate and Restart 菜单选项,这似乎没有解决问题.如何让 Android Studio 正确解析此导入?

I had tried the File > Invalidate Caches/Restart > Invalidate and Restart menu option, which doesn't seem to have cured the problem. How can I get Android Studio to correctly resolve this import?

推荐答案

首先将您的项目与 gradle 同步并检查它是否给出了一些错误,如果它工作正常,请返回并尝试从您的任何类中的 actionbarsherlock 库导入一些内容.

First sync your project with gradle and check if it gives some error, if it worked fine go back and try importing something from actionbarsherlock library in any of your class.

如果以上步骤没有帮助.检查一次 Your_Project/your_module/build/exploded-bundles/ComActionbarsherlock.../classes.jar 是否存在.

If above step doesn't help. Check once Your_Project/your_module/build/exploded-bundles/ComActionbarsherlock.../classes.jar exists or not.

那就去做吧:

Build > 清理你的项目Clean Project,将你的项目与 gradle 同步,然后检查这个以供参考.

Clean your project from Build > Clean Project, sync your project with gradle than check this for reference.

在 Android Studio 中导入 Google Play 服务库

或按照以下步骤操作:

  • 退出 Android Studio
  • 从项目中删除所有 .iml 文件和 .idea 文件夹中的文件
  • 重新启动 Android Studio 并等待项目与 gradle 完全同步

这是 Android Studio 0.4.2 中的错误,已针对 Android Studio 0.4.3 版本修复.

This is bug in Android Studio 0.4.2 and fixed for Android Studio 0.4.3 release.

这篇关于Android Studio 项目无法解析 ActionBarSherlock 导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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