[英]android studio cannot find “Activity” symbol
I have tried to create and run hello world
new app using Android studio.
我尝试使用
Android studio.
创建和运行hello world
新应用程序Android studio.
however i cannot compile as it says it's cannot resolve Activity
symbol.但是我无法编译,因为它说它无法解析
Activity
符号。
and also other basic symbols in the black template.以及黑色模板中的其他基本符号。
I suggest adding/configuration the JDK.我建议添加/配置 JDK。
I guess I'm doing this wrong, because I have tried to add the JDK
and the problem re-occurred.我想我做错了,因为我试图添加
JDK
并且问题再次发生。
how to solve this?如何解决这个问题?
UPDATE1更新1
couldn't find external build找不到外部构建
Android studio 0.2.6安卓工作室 0.2.6
Android Studio安卓工作室
File -> Invalidate Caches / Restart文件 -> 使缓存无效/重新启动
It Worked for me.它对我有用。
确保导入 android.app.Activity。
import android.app.Activity;
I ran into this problem as well and it was driving me crazy.我也遇到了这个问题,这让我发疯了。 Here is what worked for me:
这是对我有用的:
I noticed that Under File|Project Structure the Classpath for my selected android SDK (Android 4.3 Google APIs) was blank.我注意到在 File|Project Structure 下,我选择的 android SDK(Android 4.3 Google API)的类路径是空白的。
I changed the Build target to a different SDK, then switched back and the Classpath tab became properly populated.我将 Build 目标更改为不同的 SDK,然后切换回来并且 Classpath 选项卡正确填充。 Once I did that, android symbols were resolved in my project.
一旦我这样做了,android 符号就在我的项目中得到了解决。
If you don't see pathtosdk/android-##/android.jar listed in the classpath, this could be your solution.如果您没有在类路径中看到 pathtosdk/android-##/android.jar,这可能是您的解决方案。
As addition, if all solutions you have tried getting no result, in my case, make sure your activity already defined on AndroidManifest.xml
.另外,如果您尝试过的所有解决方案都没有结果,就我而言,请确保您的活动已在
AndroidManifest.xml
定义。
<activity
android:name=".Main2Activity"
...
></activity>
This happens when I create activity manually by creating Activity Class directly without building from template (right click -> new -> activity -> Empty Activity/other templates ) .当我通过直接创建活动类而不从模板构建来手动创建活动时会发生这种情况(右键单击 -> 新建 -> 活动 -> 空活动/其他模板) 。
我在文件 -> 项目结构中更改了我的模块版本,更改为我下载的最新版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.