Java 无法解析 android.content.Context 类型。它是从所需的 .class 文件间接引用的
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18509324/
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
The type android.content.Context cannot be resolved. It is indirectly referenced from required .class files
提问by bapi
I got solution(it worked for someone) for my problem:
我为我的问题找到了解决方案(它对某人有用):
Error with Autogenerated file BuildConfig.java - Android
自动生成的文件 BuildConfig.java 出错 - Android
Actually I do not have idea how to do this in Sybase unwired platform/eclipse:
其实我不知道如何在 Sybase 无线平台/eclipse 中做到这一点:
"Fix project properties". Right click project-->android tools.
“修复项目属性”。右键单击项目--> android 工具。
Note: I have generated code in Sybase unwired platfrom V2.1.3 for Android device.After this automatic code generation I'm getting this error, in following method:
注意:我已经在 Sybase unwired platfrom V2.1.3 中为 Android 设备生成了代码。在这个自动代码生成之后,我收到了这个错误,方法如下:
The type android.content.Context cannot be resolved. It is indirectly referenced from required .class files
无法解析 android.content.Context 类型。它是从所需的 .class 文件间接引用的
public static synchronized void setApplication(com.sybase.mobile.Application app)
{
com.sybase.sup.client.mbs.RegistryUtil.setApplicationContext(app.getInstance().getApplicationContext());
initialize();
}
How to solve this? Thanks.
如何解决这个问题?谢谢。
采纳答案by bapi
Adding jar from Android SDK path...cleared the error. :)
从 Android SDK 路径添加 jar...清除了错误。:)
Josh Edit: Basically I copied the file android.jar from my computer and added it to the path of my Sap Mobile Platform project, which is running on a remote virtual machine. These are the detailed steps (We all love detailed steps):
Josh 编辑:基本上我从我的计算机复制了文件 android.jar 并将其添加到我的 Sap Mobile Platform 项目的路径中,该项目在远程虚拟机上运行。这些是详细步骤(我们都喜欢详细步骤):
go to: YourAndroidSDKPath\sdk\platforms\android-17 (instead of 17 go to your version number)
转到:YourAndroidSDKPath\sdk\platforms\android-17(而不是 17 转到您的版本号)
...and copy the file android.jar somewhere else
...并将文件 android.jar 复制到其他地方
Now, go to your SMP project, highlight the red "app.getInstance().getApplicationContext()" code where the error is, so that a yellow popup appears, with a hyperlink to "Fix Path"
现在,转到您的 SMP 项目,突出显示错误所在的红色“app.getInstance().getApplicationContext()”代码,以便出现黄色弹出窗口,并带有指向“Fix Path”的超链接
Go to the Library tab, click on add external JAR, and browse to the android.jar file that you copied before.
转到库选项卡,单击添加外部 JAR,然后浏览到您之前复制的 android.jar 文件。
Voila!!
瞧!!
回答by Puzzle
Right click the project -> Properties -> Java Build Path -> Libraries -> Add Library -> Android Clathpath Container -> Select your project from avaliable projects in your workspace -> Finish.
右键单击项目 -> 属性 -> Java 构建路径 -> 库 -> 添加库 -> Android Clathpath 容器 -> 从工作区中的可用项目中选择您的项目 -> 完成。
回答by BraydenJW
I also had this same problem. The solution ended up being that I was using the Android SDK when I needed the Google APIs SDK. Right click project > Android > Select one of the Google APIs checkboxes, then clean and build.
我也有同样的问题。最终的解决方案是,当我需要 Google APIs SDK 时,我使用的是 Android SDK。右键单击项目 > Android > 选择 Google API 复选框之一,然后清理并构建。