简体   繁体   中英

Why i'm getting errors when creating a new eclipse android project?

In Eclipse i'm going to File > New > Other > Android Application Project I give a name then click next next next finish when it's creating the new project i'm getting errors in the console window:

error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'

6 errors all in styles.xml

Also i'm getting errors in the MainActivity.java and i didn't change anything didn'nt even open the MainActivity.java yet.

This is the main activity java code i didn't touch or changed anything.

package com.example.texttospeech;

import android.support.v7.app.ActionBarActivity;
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);
    }
}

All packages in the android sdk manager already installed. i'm targeting the project to compile on minimum 7 maximum 18.

First it was 21 so i created new project targeting and compiling 18.

But same errors. I didn't have it before.

I remember i deleted a project name: appcompat_v7 maybe i need this ? If so how to get it ?

Anyway i googled and so far no solution for me.

Go to the android sdk folder-> extras -> android -> support -> v7

Import the appcompat folder present in v7 folder in eclipse and then add this library to your project. This should solve your problem.

Do the following steps , this may help:

  1. import android.app.Activity; paste this line in imports
  2. Replace ActionBarActivity with Activity.
  3. Remove all methods except onCreate for now.
  4. Clean and Rebuilt project.

if problem still persist , restart eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM