My R class is not creating ids of my UI elements - android

This is the image of my main_avtivity:
This is the image of my activity_main.xml layout:
I have imported com.example.calculator.R class. I even tried to clean the project so many times. I even made a new Project two times. Moreover my ADT Plugin is properly installed. Plz help me. I have done everything mentioned in other StackOverflow answers but nothing seems to be working for me.

R.java won't generate properly if there are errors in your XML files. So look through your XML files and look for any possible issues. The errors in the console at the bottom of your second screenshot would be a good place to start.

First SaveAll your changes then go to project>Clean Project and Build it again. Its seems like you didn't save your project.

Related

Views getting flagged inside CardView

Everything with my android studio was working fine until I came across this weird thing that when I add Views inside a CardViewthe IDE is warning me telling that for example "TextView is not allowed here". I have done this a thousand times before and It was absolutely fine.
Here is a List of the things I have tried
1. Restarted the IDE.
2. Restarted the entire system.
3. Tried the Invalidate Caches/Restart thing.
4. Cleaned the peoject.
5. Verified the support library version and files
6. Banged my head against the wall.
Nothing worked, here are some additional details
IDE version 1.3.1, SDK tools is using API 22 fully updated
And one more thing is suggestions are not shown under the CardView in XML, i guess both these problems are related.
I have seen a similar question here, but unfortunately it didn't help me.... Please someone find a fix for this problem...
Well after spending a day searching around in the Intelli J IDEA docs, I was able to find a solution for this problem. It has to do with the corrupted project metadata and other project related data that is common across projects loaded into Android Studio, so naturally I just opened a backup of my project that I had backed up when the problem did not exist. And I solved it....
Hope this'll help you...

Android ActionBarCompat Not working from the start

OK, I have been wanting to try the new ActionBarCompat, however, I am not able to run my programs in the emulator.
I have been trying to implement the following: http://antonioleiva.com/actionbarcompat-how-to-use.
and have been stuck on basically the first part. However, working with the author of that content, I was able to get further as I was not adding the project under sdk\extras\android\support\v7\appcompat folder like stated. However, I still think that might be the reason I cannot do this...
More detail can be found here: http://antonioleiva.com/actionbarcompat-how-to-use/#comment-43
Basically, on my first attempt, I just created an Android project, and changed the source code as indicated. Code would not run on the emulator. So I went back to the original code, and that ran on the emulator.
Checked online, found out I might need to add the \extras\android\support\v7\appcompat folder as a library to the project I am building. So I added that and a new android project was created. There were build errors from the start, but I failed at trying to add it as a library to my project, and deleted it....thinking this was way overboard.
After back and forth chats with author of linked website, I found out I had to do that overboard thing.
So I tried the following link to the T: (I cannot post more than 2 links due to low repuation...I will add this link as a comment below)
However, Eclipse would not allow me to add the appcompat Existing Android Project...but it did allow me to add the appcompat Existing (General) Project. I think this may be some of the problems??
Right now, I cannot run the project at all. Eclipse is showing a red exclamation mark on the project folder, but all the code seems to be fine. So I don't know what to do now...I recreated this project several times over, and this one was the one where I knew what to do...and I am still getting problems
So...
I decided to move to Android Studio...updated the IDE, updated the SDK manager to include the new support library, and other things. Created a new project, added to the build.gradle file as shown in the link provided below in the comment. I ran the ant build, and then built the project...tried to import the right things to allow ActionBarActivity, but I could not get that far.
I can import
"android.support.v7.*"
"android.support.vy.R" // and all folders within
but nothing allows me to add ActionBarActivity, and I don't know why.
FYI, I guess I would prefer a solution to Ecplise, as it seems like I actually got somewhere with it.
The best example to use is from here, and I would follow it closely. I had similiar issues when I first came across this. Problem was I misunderstood what I needed to do
http://developer.android.com/tools/support-library/setup.html#libs-with-res

R.java's values not recognized

I downloaded a an android project folder from a friend (the app works). In eclipse, I created a new Android project from existing code. However, there are errors at the lines calling the layouts/ids from R.java. Example: R.layout.my_layout
I tried cleaning the project, and deleting the project and creating it again. The code should be working. I checked R.java to make the sure the name matches. Note that I am an advanced-beginner at Android, so I know the basics. Please help, thanks.
if you downloaded the project from a friend, you shouldn't be creating a completely new project, but choose "new project from existing source".
try looking in the project properties under Android, many times, the import screws up the properties and moves the target SDK to the lowest possible and you'll need to change that"
it sounds stupid- but try clearing you project, make a simple change in code, save and rebuild.
i hope that'll fix your problem,
another thing- make sure u didnt imported any android.R.### class - if u did erase those lines.
Wops.
What errors are you getting in console from eclipse? Error messages are usually need to help. My only suggestion without seeing the build errors is to check your import statements. Sometimes eclipse inserts bogus import to the R classes.

android not able to locte IDs

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.

Android XML Content Type Errors after Update

After updating (to the just released updates) a problem occurs: I get an Error message "Unsupported Content Type in Editor"
The quick error dialog say's that the layout xml is 'illformed'. Not sure that has anything to do with it (as these all worked before). If I click the link in the dialog panel and make an association - same problem occurs (even after rebooting Eclipse).
When I expand the layout xml to the full list of errors, the top two errors are:
org.eclipse.core.runtime.CoreException:
Error opening the Android XML editor.
Is the document an XML file? at
com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor.createTextEditor(AndroidXmlEditor.java:617)
Any ideas ??? Obviously I can't open it to see what the 'illformed' issues are and, ALL these projects worked fine before the update...
UPDATED
If you experience the same/similar problem, add to the list at http://code.google.com/p/android/issues/detail?id=15003
The Problem follows but, here's a Workaround that worked for me: Make the association of the xml to the Android Layout Editor via Eclipse Pref's - associating them from the problem dialog doesn't appear to work. Then, restart Eclipse. This is a project per project needed change.
I had the exact same issue today. I'm assuming that you've done it already - but just in case - a restart of Eclipse made the issue go away for me.
Im posting here to other users know how to fix this issue. A simple way to get out of the problem for now: rename the XML file you want to see and the Android Builder will recognize the XML file.
i had the same problem after updating to latest SDK (honeycomb). It happened only on existing projects loaded into eclipse but not on new project. My solution was to delete the project first (do not delete the project source code) then import the project again, it works perfectly.
open that xml file in another editor and put the following line in start:
<?xml version="1.0" encoding="utf-8"?>
That problem is the result of the newly installed plugin. Uninstall it!

Categories

Resources