Migwell
Migwell

Reputation: 20117

How do I point Android Studio at my Java files?

I mostly destroyed my android studio project by accident, and in trying to rebuild it, I've come to a point where the project won't run because it can't find my MainActivity - a java file - because the AndroidManifest.xml throws an error saying 'cannot resolve symbol MainActivity'. edit: I know where this file is located, it's in the src directory, but android studio doesn't seem to know that, so can't start the MainActivity.

Where is the path to these files set? ie, where does a module look for it's own java files? It doesn't seem to be in the Android facet section, that's only the paths to resources and assets, libraries and the manifest file, but that's the sort of thing I'm looking for.

Thanks!

Upvotes: 2

Views: 3433

Answers (2)

tim_hutton
tim_hutton

Reputation: 878

I had the same problem. The cause for me was that I'd imported a source file from a different project and the package specifier at the top of the .java file was wrong:

package com.example.android.opengl;

Instead it should have referred to my current project.

Upvotes: 0

Stephan Branczyk
Stephan Branczyk

Reputation: 9375

Right-click on your myproject folder > Mark as Directory > Source Root

Upvotes: 5

Related Questions