1

I started a new project in eclipse android but there was a 3 errors in the beginning. I made a new project again but I had them again. There wasn't these errors before can anyone help ? these are first default codes main activity:

package com.persiansmarthome;

import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @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;
    }

}

These are the errors:

Description Resource Path Location Type activity_main cannot be resolved or is not a field MainActivity.java /PersianSmartHome/src/com/persiansmarthome line 15 Java Problem

Description Resource Path Location Type main cannot be resolved or is not a field MainActivity.java /PersianSmartHome/src/com/persiansmarthome line 22 Java Problem

Description Resource Path Location Type Don't include android.R here; use a fully qualified name for each usage instead MainActivity.java /PersianSmartHome/src/com/persiansmarthome line 5 Android Lint Problem

John Koerner
  • 37,428
  • 8
  • 84
  • 134

2 Answers2

1

Remove this line:

import android.R;

from your MainActivity.java file

For more details, look at R cannot be resolved - Android error.

Community
  • 1
  • 1
VJ Vélan Solutions
  • 6,434
  • 5
  • 49
  • 63
  • if i remove that line other problem happens –  Dec 02 '13 at 22:02
  • @user2921883 I have edited my answer to provide more details on the android.R issue. Your app should be using the R.java that's generated for you (located under gen folder at your project root) and not the android's resource file (android.R) – VJ Vélan Solutions Dec 02 '13 at 22:08
0

Try to increase the minimum sdk version in manifest.xm

Sounds like incorrect sdk / api version. Check also your sdk version in your project properties and make sure you installed the relevant sdks in sdk manager

ItayB
  • 10,377
  • 9
  • 50
  • 77
  • i changed min and target sdk many diffrent values but errors are not gone. what else problem can be? it wasnt before. –  Dec 02 '13 at 22:23
  • What is your min/target sdk? which api's are installed on your computer? – ItayB Dec 03 '13 at 07:03
  • the last one. i think its 17 and minimumm of my project is android 2.2 –  Dec 03 '13 at 11:12
  • Try to change to 10, make sure 10 is installed in your sdk manager – ItayB Dec 03 '13 at 19:43