I really don't know which information to put in here because the problem is so silly and ridiculous that I don't have a clue as to what might matter in order to understand it.
I was just working on a project yesterday night and after encountering a nasty android "bug"? (something to do with bitmaps disappearing from internal memory) I decided to shut down and keep on working today.
This morning I opened IntelliJ and suddenly the xml layout preview goes crazy:
NOTE: One or more layouts are missing the layout_width or
layout_height attributes. These are required in most layouts. Or:
Automatically add all missing attributes Couldn't resolve resource
#string/app_name (46 similar errors not shown) "#dimen/logo_font_size"
in attribute "textSize" is not a valid format. (Edit) (25 similar
errors not shown)
It says that some layout_width or layout_height is missing, but none of these attributes is missing from any element. I know because the project won't build if there is such an error and I built the same project multiple times yesterday without any problems.
Additionally, every string, dimen and color resource cannot be resolved anymore even if the files are still there unchanged.
I did not pull from git or any other repository. I did not modify the project in any way in the meantime, and xmls have been left untouched. I did not install any android sdk component, tool or update in the meantime.
I already try to restart IntelliJ many times; I also tried to rebuild the project; but nothing works.
Related
Noob Android Studio 3.6.1 on Mac Mojave developer here. I have a very simple app with a few activities. Every so often, the Kotlin class for one of the activities will complain of an unresolved reference to the corresponding layout XML file.
For example, in the Kotlin Class (TraceActivity.kt), I have the following code:
setContentView(R.layout.activity_trace)
and the corresponding XML file lives at:
MyApp/app/src/main/res/layout/activity_trace.xml
All pretty standard stuff I reckon. But setContentView would complain that it couldn't resolve activity_trace. This has happened on a few occasions, and I discovered that restarting would resolve the problem. But this morning, it isn't helping. And it's also started complaining about some of the strings I've added to strings.xml
I managed to get round the errors by making use of the full names for each of the items e.g.
com.mysite.myapp.R.layout.activity_trace
and
com.mysite.myapp.R.string.my_message
So my guess (as a noob) that somewhere it's losing track of where it is. And yet my other activities are perfectly happy when I omit the full location. Can anyone offer some insight here? Thank you - SO is awesome.
I had several layouts for various size devices and at each orientation. Somehow, they've all disappeared and only the original layout shows again, no matter which device type or size or orientation I select in Android Studio's renderer.
I've upgraded Android Studio. I've renamed the parent folder the source project and files were in. I've upgraded the sdk. Also, Although my app is not a Gradle project, I did something the IDE kept bugging me to do... I believe I moved something from AndroidManifest to build.gradle.
I don't know which step caused me to lose my layouts, as I didn't notice as I worked on other things.
Does anyone have any idea what I might have done that would cause my layouts to disappear?
Thanks.
They have not disappeared and you have not lost them!
Click on the drop down which I have circled (It probably says Android for you) and choose "Project" view which is what you were used to before the update.
I had a fully working app, but today when I opened it in eclipse it could not find any of my resource ids(Buttons, EditTexts, TextViews, and layouts). I have no clue why this is happening. It is as though I forgot to give my buttons an id in XML, but when I go to the files they are still there.
Has anyone else had this problem/know how to solve it ?
EDIT:
I should also add that if I look in R.java , all my ids are there
i faced the same issue. i checked the AndroidManifest file same code repeated two times. so i
removed the repeating tag from the xml
after that i clean and compiled, then it was working fine.
also check your adt version version. make sure that is upto date.
I looked up on getting an emulator for a tablet and noticed a suggested that on checking for updates within eclipse , the latest SDK/ADT etc would provide this. At the moment I cannot check this because I am getting the following error on my main.xml file.
error!
NotFoundException: null
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- ToggleButton (Change to android.widget.ToggleButton, Fix Build Path, Edit XML)
I have tried the three options it offers and on choosing edit XML nothing appears to show an error.
This project runs under Android 1.6 (wanted to make it as backward compatible as possible) and trying to cope with different screen sizes and orientations . At the moment I have the following layout folders:
layout(empty folder)
layout-large
layout-normal
layout-normal-land
layout-small
layout-xlarge
These all existing before the eclipse/android updates and I never had these errors. I searching the net on these , I read one suggestion of Project->clean (done this) and I then did Project->Build.
I also a suggestion to remove r.java so I have done this and ran clean and build. Still getting the same error. Oddly the code and the xml show no signs of errors apart from the above message appears at the bottom of the designer window for the XML.
The designer is set to 1.6 (API4) so it is not that the designer thinks I am on a different version to my project.
Update 1:
Since moving onto 2.1 - I found that although the layout does not show the error straight away, it then appears if I try and make any changes to it. Also I have updated the images and these do not appear to have changed either.
Update 2:
feco has suggested a reasonable suggestion of moving the build target to 2.1 as only a small percentage of users operate with a 1.6 handset now. I have decided to do this , it is more of a get around than a solution but it will have to do right now.
I had the same problem. I solved it by changing from API4 to API10 (or more) in the "Graphical Layout" window -> upper menu -> Android logo (green robot) at the end
So I've been working on this project all day, and no problems. I add an id to a layout element in one xml file, which is not being recognized by the IDE (all other IDs are, but this one isn't). I've run into things like this before over the past couple days, and a "Project > Clean" usually fixed it. So I did so - and virtually every one of my files that references R.anything comes up with the red X - I look and see that R.java isn't being created.
I searched SO and found a couple solutions about turning on or off "Build Automatically" and tried that - no luck - someone else said try setting target to 2.2 - tried that, no luck. Tried deleting it manually, tried recreating it and adding it as source - no good. Restarted eclipse, and tried everything again, without success.
As I said, I must have compiled this thing 100 times tonight, and the only change I made between working fine and failing is adding an id to an element (which I've since removed).
If you have a corrupt XML-file and try to rebuild your R.* it will fail. You should go through your xml-files and make sure that they are all error-free. It's likely you have a misspelling or other small problem somewhere that prevents the build.