1

Hey guys after updating Eclipse (Help -> Check for Updates) and Android-SDK-Manager I always get the "…cannot be resolved to a type" or "…cannot be resolved to a variable" message. I get this Error-Message at every single project I already had created as well as on new ones.

I have already tried those things but none of them worked out for me:

  1. Project -> Clean...
  2. Right click at the project -> Properties -> Java Build Path -> Libraries -> Add Library... -> JRE System Library my apps dont run after update eclipse & adt
  3. Window -> Preferences -> Java -> Compiler -> Building -> [x] Rebuild class files modified by others

All those three steps didn't solve those error messages...maybe someone else has an idea what to do? Reinstall Eclipse should be the last option…it totally toke me forever to connect Eclipse with GitHub :(

Example Code:

package com.example.test;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

Error messages:

ActionBarActivity cannot be resolved to a type  MainActivity.java   /TestProject/src/com/example/test   line 7  Java Problem
ActionBarActivity cannot be resolved to a type  MainActivity.java   /TestProject/src/com/example/test   line 11 Java Problem
ActionBarActivity cannot be resolved to a type  MainActivity.java   /TestProject/src/com/example/test   line 31 Java Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.   styles.xml  /TestProject/res/values-v14 line 8  Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml  /TestProject/res/values line 7  Android AAPT Problem
error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml  /TestProject/res/values-v11 line 7  Android AAPT Problem
R cannot be resolved to a variable  MainActivity.java   /TestProject/src/com/example/test   line 12 Java Problem
R cannot be resolved to a variable  MainActivity.java   /TestProject/src/com/example/test   line 18 Java Problem
R cannot be resolved to a variable  MainActivity.java   /TestProject/src/com/example/test   line 28 Java Problem
The method getMenuInflater() is undefined for the type MainActivity MainActivity.java   /TestProject/src/com/example/test   line 18 Java Problem
The method onCreate(Bundle) of type MainActivity must override or implement a supertype method  MainActivity.java   /TestProject/src/com/example/test   line 10 Java Problem
The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method MainActivity.java   /TestProject/src/com/example/test   line 16 Java Problem
The method onOptionsItemSelected(MenuItem) of type MainActivity must override or implement a supertype method   MainActivity.java   /TestProject/src/com/example/test   line 23 Java Problem
Community
  • 1
  • 1
3dDi92
  • 227
  • 3
  • 4
  • 9

2 Answers2

0

Sorry I can't put this into a comment, but I don't have the reputation required to do so. Try to go to window -> show view -> problems.

It should display all eclipse-related problems as well as the problems with your code. If there are any eclipse related issues, could you post them? I know I had a problem with the android-eclipse bundle -- I ended up having to download the 32 bit libraries even though I am using a 64 bit OS. It worked immediately afterwards, and all it took was checking the problems view.

Secondly, if you've tried project -> clean, and that didn't fix it, then it probably has nothing to do with the automatic file generation files being deleted, like the appcompat_v7 folder, as it would regenerate upon clean. It is most likely a missing library issue.

Please post the results of this operation.

Alexander Guyer
  • 2,063
  • 1
  • 14
  • 20
  • I have already listed all the problems that occur in this view (`Problems`) in my first post. – 3dDi92 Oct 07 '14 at 07:25
  • I did not realize that those were an output of the problems view, as I thought they were errors upon compilation / run. If the package these files are in is not the default package, try importing R.java. (If they are from the default package, try import com.example.test.R, but this will most likely cause some errors in itself.) – Alexander Guyer Oct 09 '14 at 00:04
0
@ridvanzoro Deleting the appcompat_v7 folder fixed the problem for new projects. I now can try to remove all of my old projects and import them. Thanks :)

You do not need to delete appcompat_v7, there are good xml files , animations inside this folder, you may want use them. To change or remove appcompat_v7 folder from your project,

Right click at project->Build Path->Configure Build Path->Lİbraries Tab->Android Dependencies 
ridvanzoro
  • 646
  • 1
  • 10
  • 25