2

Iam a newbie to android.I had crested an project to check the textfields avaiable in android. I added some resources in string.xml and build the project. My R.java is not generated automatically. I had choosed only "Build Automatically" from project tab. I had cleaned my project many times and restarted eclipse but my r.java is not generated. I cant find any error with my resource folder. Can anybody help me out of this? and also give me some instructions how to work with resource folder if possible?. please refer my activity.xml below.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Text_MainActivity"> 

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<EditText
    android:id="@+id/email_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="14dp"
    android:ems="10"
    android:hint="@string/email_hint"
    android:inputType="textEmailAddress"/>

<EditText
    android:id="@+id/launch_codes"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/email_address"
    android:layout_below="@+id/email_address"
    android:ems="10"
    android:hint="@string/enter_launch_codes"
    android:imeActionLabel="@string/launch"
    android:inputType="number"/>

<EditText
    android:id="@+id/postal_address"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/launch_codes"
    android:layout_below="@+id/launch_codes"
    android:ems="10"
    android:hint="@string/postal_address_hint"
    android:inputType="textPostalAddress"/>

<AutoCompleteTextView
    android:id="@+id/autocomplete"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/postal_address"
    android:layout_below="@+id/postal_address"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="18dp"
    android:ems="10"
    android:hint="@string-array/countries_array">
</RelativeLayout>

Thanks in advance

ASP
  • 3,645
  • 1
  • 31
  • 45
  • open the problems view from eclipse. It will give you hints on the issue – Blackbelt May 20 '13 at 09:41
  • @WinPhone7User Check all your xml files for errors. – Nikhil Agrawal May 20 '13 at 09:42
  • did this happen after sdk and adt plugin update? If not cross check your resource files again – Raghunandan May 20 '13 at 09:45
  • 'android:layout_alignLeft="@+id/textView1" android:layout_below="@+id/textView1"'.... is it possible to put both together...?? – ASP May 20 '13 at 09:59
  • Which version of ADT are you using, Is it version 22? – Paresh Mayani May 20 '13 at 10:01
  • if you are using version 22 as @PareshMayani said check the link for the answer http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127 – Raghunandan May 20 '13 at 10:04
  • If you are using ADT ver 22 then here is the answer: [**Eclipse error: R cannot be resolved to a variable**](http://stackoverflow.com/questions/16642604/eclipse-error-r-cannot-be-resolved-to-a-variable/16643060#16643060) – Paresh Mayani May 20 '13 at 10:05

2 Answers2

1

This has been asked many times before and possibly a duplicate question.

But again, you can try to Clean and Rebuild the project. If the problem continues, look into res/ folder, you'll probably see a red X icon that shows you that one of the XML files are broken. Fix that XML and it may work.

By the way, it seems like you are not closing AutoCompleteTextView tag in your xml.

frankish
  • 6,738
  • 9
  • 49
  • 100
  • agree, There must be some error in you xml file. double check all of them. – Jeff Lee May 20 '13 at 09:44
  • i had checked all my XML there is no error. iam not seeing any red cross even. I had cleaned and rebuild-ed my project several times. but iam repeating with this error. –  May 20 '13 at 09:59
  • Change ``to `` – frankish May 20 '13 at 10:00
  • I had added "/" also and checked.but no use –  May 20 '13 at 10:02
  • @WinPhone7User check the link may help you. http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127 – Raghunandan May 20 '13 at 10:04
  • Hi guys, Thank you........ I referred this link as suggested stackoverflow.com/questions/16636039/. I found my build tool has been uninstalled. after installing that. once i clean my project. iam able to run.. –  May 20 '13 at 11:02
0

Before building your project, right click on Android project, goto --> Android tools ---> Fix project properties. after completed this, then right click on project and ---> build project

it may resolve your issue.

nanithehaddock
  • 247
  • 1
  • 9