Android Studio 提示“无法解析符号"但项目编译 [英] Android Studio says "cannot resolve symbol" but project compiles

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

问题描述

我正在 AndroidStudio 中导入 twitter4j,在我的 build.gradle 中使用以下内容:

I'm importing twitter4j in AndroidStudio, using the following in my build.gradle:

dependencies {
  compile 'com.android.support:support-v4:18.0.+'
  compile files('libs/twitter4j-core-3.0.4.jar')
}

该项目编译良好,我可以毫无问题地创建 twitter 对象.但是,在 Android Studio 中,任何引用该库的内容都显示无法解析符号"并以红色显示.我需要做什么才能让 Android Studio 识别库?

The project compiles fine, and I can create twitter objects without a problem. However, in Android studio, anything referencing that library shows "cannot resolve symbol" and displays in red. What do I need to do to get Android Studio to recognize the library?

我已经尝试重建项目,./gradlew clean,关闭并重新打开我的项目.

I have already tried rebuilding the project, ./gradlew clean, and closing and re-opening my project.

推荐答案

不知道这是否可行,但我目前唯一的想法是:右键单击 AS 内文件树中的 jar 文件,然后选择添加为库..."

No idea if this will work or not but my only thought so far: right click the jar file in file tree within AS and select "Add as library..."

您可以执行文件"->使缓存无效...",然后选择无效并重新启动"选项来解决此问题.

编辑 2:此修复程序应该适用于所有类似事件,而不是 twitter4j 特定的解决方案.

这篇关于Android Studio 提示“无法解析符号"但项目编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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