Elad Benda
Elad Benda

Reputation: 36656

android studio cannot find "Activity" symbol

I have tried to create and run hello world new app using Android studio. however i cannot compile as it says it's cannot resolve Activity symbol.

and also other basic symbols in the black template.

I suggest adding/configuration the JDK.

I guess I'm doing this wrong, because I have tried to add the JDK and the problem re-occurred.

enter image description here

how to solve this?

UPDATE1

couldn't find external build

enter image description here

enter image description here

Android studio 0.2.6

Upvotes: 23

Views: 31846

Answers (5)

Azade Rahmati
Azade Rahmati

Reputation: 207

i changed my module version in file -> project structure, to last version i've downloaded

Upvotes: 0

Aldy
Aldy

Reputation: 3102

As addition, if all solutions you have tried getting no result, in my case, make sure your activity already defined on 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 ).

Upvotes: 0

Justin Russo
Justin Russo

Reputation: 2214

Make sure to import android.app.Activity.

import android.app.Activity;

Upvotes: 9

Manoj Behera
Manoj Behera

Reputation: 2815

Android Studio

File -> Invalidate Caches / Restart

It Worked for me.

Upvotes: 42

slund
slund

Reputation: 6397

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.

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.

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

Upvotes: 4

Related Questions