Java android studio找不到“活动”符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18637559/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 09:44:42  来源:igfitidea点击:

android studio cannot find "Activity" symbol

javaandroidandroid-studio

提问by Elad Benda

I have tried to create and run hello worldnew app using Android studio.however i cannot compile as it says it's cannot resolve Activitysymbol.

我尝试使用创建和运行hello world新应用程序,Android studio.但是我无法编译,因为它说它无法解析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 JDKand the problem re-occurred.

我想我做错了,因为我试图添加JDK和问题再次发生。

enter image description here

在此处输入图片说明

how to solve this?

如何解决这个问题?

UPDATE1

更新1

couldn't find external build

找不到外部构建

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

Android studio 0.2.6

安卓工作室 0.2.6

回答by slund

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. Once I did that, android symbols were resolved in my project.

我将 Build 目标更改为不同的 SDK,然后切换回来并且 Classpath 选项卡正确填充。一旦我这样做了,android 符号就在我的项目中得到了解决。

If you don't see pathtosdk/android-##/android.jar listed in the classpath, this could be your solution.

如果您没有在类路径中看到 pathtosdk/android-##/android.jar,这可能是您的解决方案。

回答by Manoj Behera

Android Studio

安卓工作室

File -> Invalidate Caches / Restart

文件 -> 使缓存无效/重新启动

It Worked for me.

它对我有用。

回答by Justin Russo

Make sure to import android.app.Activity.

确保导入 android.app.Activity。

import android.app.Activity;