Android, "cannot find symbol" error for my own class

Hi,

I've been using the latest (I think 12.1) version of Intellij IDEA for Android development for about a month now and I've just come across a large issue. I'm getting a "cannot find symbol" error on one of my activity classes called "MainActivity". I've been doing a lot of research and haven't found a suitable solution so far.

What I understand is that the compiler can't find the symbol because the ".class" files that are supposed to be generated are not present and can therefore not be found. I noticed that the ".class" files for my "MainActivity.java" file were deleted after I had tried to change up the libraries used by the project. I added a library containing all of the ".jar" files that I needed and added that library in the "Modules" screen under "Project Settings" which is reached by first going to "Project Structure" like so:

Project Structure | Project Settings | Modules

So, when I updated the modules with the new library I found by looking at a "git status" command that all of my "MainActivity$InnerClassName.class" files were gone and thus couldn't be used to compile and run the project. I've tried removing and adding in the "MainActivity.java" file, rebuilding the project (which gets hung up on the same error as a regular compile and run), I've tried every configuration of "Project SDK" and "Module SDK" I can think of and I'm at a complete loss. Is there a way to get Intellij to generate the necessary ".class" files?

Any help with this would be amazing! I've also tried to revert back to a usable version of my code with Git but I need to make changes to the libraries and changing them makes things crash. Please let me know what other information I need to give to help get this fixed. I left out actual code snippets as the info is sensitive but I could post code if necessary, I'll just have to make some changes.

Thanks,
jdawes

Here is the error:

java: /Users/path/to/project/SplashScreenActivity.java:22: cannot find symbol
symbol: class MainActivity

Here is the output of a "git status" command:

deleted:    out/production/project/path/MainActivity$SectionsPagerAdapter.class
deleted:    out/production/project/path/MainActivity$CustomFragment$1.class
deleted:    out/production/project/path/MainActivity$CustomFragment.class
deleted:    out/production/project/path/MainActivity$CustomListFragment.class
deleted:    out/production/project/path/MainActivity$CustomAdapter $1$1.class
deleted:    out/production/project/path/MainActivity$CustomAdapter $1.class
deleted:    out/production/project/path/MainActivity$CustomAdapter $WorldHolder.class
deleted:    out/production/project/path/MainActivity$CustomAdapter.class
deleted:    out/production/project/path/MainActivity.class

7 comments
Comment actions Permalink

Hi Jeffery,

Could you provide minimal but complete standalone project which illustrates the problem?

Denis

0
Comment actions Permalink

I'll try to recreate now, sure. This might take a little while...

0
Comment actions Permalink

Hi Denis,

I'm unable to recreate the issue, which kind of sucks. The project I am working on, that had the issue, was fairly large so the cause could have been any number of things I presume.

The only other piece of information I can give you about the problem is that it started occuring after I had attempted a project "Rebuild" and then changed the library things that I mention before. I don't know if that will give you enough to go on but that's all I've got. I've since reverted my changes using Git and manually typed in my code edits to ensure I've got a project that runs smoothly.

If you could find out what caused the issue I would be very greatful but I know you don't have much to work with.

Thanks,
Jeff

0
Comment actions Permalink

Hi Jeffrey,

No idea on the problem's cause, sorry, Will ask our android integration developer to have a look here.

Denis

0
Comment actions Permalink

Do you store the output directory under VCS? The files in it are generated/removed my the IDE and storing it under VCS may lead to conflicts.

0
Comment actions Permalink

Yes I do, unfortunately. I guess I'll throw those things into a .gitignore file from now on. Though I'm not sure that was the issue. But thank you for your idea, it doesn't make sense to have it under VCS.

0
Comment actions Permalink

Hi, i'm not on android but for the rest i have the same problem with ""cannot find symbol".
I readed somewhere else to do "rebuild project" but this didn't help.

[quote]Do you store the output directory under VCS? The files in it are generated/removed my the IDE and storing it under VCS may lead to conflicts.[/quote]

How can i check this, i can't even see the output folder in the project explorer but i can see it in the finder. I tried VCS some time ago but i think it's a bit confusing.

0

Please sign in to leave a comment.