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.
Related
I was editing 2 apps at the same time. One is a new idea, where I am doing some tests and the other one that is a stable app, that eventually needs small edits.
I do not how it happened but Android Studio mixed then. In fact, AS is saying that for some activities of the second, the code is the same as the first. On the example below, even the second being java coded, it shows it as xml.
If I look at the same file outside AS, using Wordpad, for example, the code is correct, i.e. it is the original like I did (see the picture).
I tried many things like cleaning cache, closing and opening AS, so many times, so many ways, etc. but nothing works. For days I am stuck on this issue. I tried even the function ´Compare with´ but it shows the (wrong) xml code.
Was not only this Activity that appears ´corrupted´ but others of the stable one.
Any idea?
On Left is the beginning of the real code; on Right how AS shows it
Try deleting the caches folder in .AndrroidStudio and restart Android studio.
Path :
C:\Users\username\.AndroidStudio3.6\system\caches
Sometimes it does so. I met the same issue and fix it by:
On your android studio top bar, go: File -> Invalidate Caches/Restart -> Invalidate and Restart.
I'm using android studio mac.
After being kicked off of reddit and told to come here, I have some massive questions.
I just started to code, I am trying to release my first app. However, right as I went to submit it, I messed up and everything is crazy now! So I will start at the beginning:
I am making an app that lets you shuffle between ideas on what to build in minecraft. Each tap brings up a new random idea - that is all. It is super simple, I am keeping it that way since it is my first ever app. Now, I had it working, I have every drawing I need for the app. But as I went to submit the app to actually publish it, my .apk file was invalid. I was using the test version, which wasn't allowed to be used in the submission.
I then followed a guide that instructed me to delete my Gradle and .Gradle folders, and apparently android studio was supposed to regenerate them and fix it. Well, that did not happen. What happened was that my 'Android' folder in Android Studio became empty - there is now an app folder with nothing in it, and a Gradle Scripts section with various files that I had not seen before. The majority of my file names are red or orange.
Now, most of if not all of my code is still here. However, it says that the Gradle project sync failed, and I don't know what that means. I can no longer find out the source of these files, as in, there is no manifests or java folder located within my 'Android' heading. I don't know what to do to get it back. I had almost everything taken care of, and I am certain there is a simple way to get it all back. I did not make a VCS at the time, since nobody ever told me I should. Like I said, I am new at making apps. I still have the folder with what appears to be every single bit of code I have made so far.
If you can help me I will be extremely grateful. I have spent almost three weeks working on this, and it would be horrible to see it all go down the drain over one simple mistake.
What about creating a new project and adding your source files, dependencies and resources to it?
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.
Every time I open an activity layout in order to view its design, I can't see anything, and there's a "Loading configuration" message. How to solve it?
Looks like this is related to the following issue: https://code.google.com/p/android/issues/detail?id=56691&q=%22Loading%20Configuration%22&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
I had the same issue and it got solved by using the menu item: File->Invalidate Caches/Restart
Try to delete the build folder.
Here are the details:
Yesterday(2015/6/10) I faced to the same problem, and I solved it by using beyond compare:
This problem occured after a forced upgrade.
I have 2 projects, one worked(newly created) and one doesn't.
So I used beyond compare to compare the 2 projects' folders.
Luckily I found build folder of the not-worked never changed even though I clear cache, restart and rebuild it several times.
build folder deleted and everything worked fine now.
I've had this issue before, and it was usually not long after an error had come up.
Check the Event Log for errors. Usually a restart of the IDE fixed it for me though I appreciate that's not ideal. The errors weren't anything specific I think just teething issues with Android Studio - tis just preview software after all.
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.