-1

I am learning android using eclipse. I created my first project.
package- com.example.testmobileapp
Min Target Ver - 3.x
Max Target - 5.1


I tried to as much as information I can gather from already asked question but unable to sort this out so finally asking here.
I included android-support-v7-appcompat.jar to resolve error and used AppCompatActivity to extend in my mainActivity class.
And as so many question already been asked to resolve the import android.R; I tried the following ways

  1. Removed the import android.R statement(which resolved some error) but R cannot be resolved to a type still lingers as it is referenced.
  2. Deleted BuildConfig.java in gen folder,Clean & Build the project as mentioned at so many places to generate R.java @ this place.<>
  3. Closed and restarted eclipse(No use)
  4. I am getting error in values/styles.xml,(please check image reference for error), I tried to correct it using this Can't Find Theme.AppCompat.Light for New Android ActionBar Support, but no luck!


Tried Urls
1. R cannot be resolved - Android, no import android.R; statement
2. import android.R in Eclipse : Why?
3. Developing for Android in Eclipse: R.java not regenerating

Please find the image reference.WorkSpace 1

enter image description here

enter image description here

enter image description here

Community
  • 1
  • 1
Narendra Jaggi
  • 1,297
  • 11
  • 33

2 Answers2

1

I am getting error in values/styles.xml,(please check image reference for error), I tried to correct it using this Can't Find Theme.AppCompat.Light for New Android ActionBar Support, but no luck!

This is your problem. Errors in your application's XML files prevent R from being generated.

After your styles.xml is without errors, the problem should be fixed.

Edit: Make sure you are using the right library project as described in the accepted answer of this SO question.

Community
  • 1
  • 1
TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
  • I am so glad u answer in this way!! Boss exactly every single person answering the same damn thing without actually telling HOW TO RESOLVE IT, THAT'S My Problem – Narendra Jaggi May 24 '15 at 18:58
  • Try to use the AppCompat Library. That is why it is unable to find the Theme. – Abhishek May 24 '15 at 18:58
  • @Abhishek Please refer the 3rd image's 3 import statement, is that what u referring or something else? – Narendra Jaggi May 24 '15 at 19:00
  • @NarendraJaggi No man you have to include the library like the way in the below answer. Once you include that library in the project, it will compile definitely. If it still fails then please let me know. – Abhishek May 25 '15 at 06:32
  • @Abhishek I should follow the TimoSta answer? – Narendra Jaggi May 25 '15 at 06:34
  • @NarendraJaggi You can follow his answer too. Both points to to the same approach. I hope your problem is solved. :) – Abhishek May 25 '15 at 06:39
0

I have faced the same issue, it happens automatically sometimes. I don't know the reason. But I got rid of the solution by this. Just try to clean the project, In the Menubar, you have Build, under that there is Clean Project, run that once.

Parth Chokshi
  • 642
  • 4
  • 16