Pregunta

I am developing an android application in Eclipse. Eclipse sometimes imports R automatically so I just click (ctrl + shift + o) to find that import and delete it. But now, every time I delete it, it will bring it back no matter how many times I delete it.

Does anyone know how to solve this problem so I will be able to compile my project?

¿Fue útil?

Solución 3

It turns out that there was something wrong with my settings. Thanks everyone for there help.

Otros consejos

Eclipse will try to construct an import statement for related types when you use auto-complete. This is a configurable option which you can disable under Eclipse's preferences dialog Java -> Editor -> Content Assist "Add import instead of qualified name" This is not configurable on a per package basis though.

I do wonder, however, what your objection is to importing your resource class. Is it that you just want references to R to always be fully qualified? I don't know of any technical reason why this might be preferable. If it's an issue of style, then I'd interject that it might be a misguided preference. Personally, I'd rather not have to regularly read source files that interspersed imported and fully-qualified class names. If your need is neither of these things, perhaps you could share more detail so that we can give you a better answer?

Are you using any android.R classes,if yes remove it. If no try to add your app.R import manually before saving the file. I know this is annoying but thats how eclipse works for auto import....

you can also try removing automatically import settings from eclipse.

In my case it was automatically added appcompat_v7 in project preferences. I have no idea how and why it is done in eclipse and mostly it causes this problem.

enter image description here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top