i am currently having a problem regarding an xml file while programming in eclipse android.
the problem is that it seems to ask for a folder called R within my project but such a folder was not created on creation of the project.
i have had a look on the internet and review other questions but i cant quite seems to find a solution.
i am trying to set an xml file for a list and this is all the code that should be needed but it can not find the .xml file at all as it seems to want a folder called R to contain it.
new ArrayAdapter<Object>(this,R.layout.edit_item_layout , theList);
anyhelp and suggestion will be well received
UPDATE of useful information
The weird part is it can find activity_main.xml which is in the same folder
the file is located in res/layout
ok i cleaned and now it is giving a list of files i can change it to but the file itself doesn't seem to be in the R.java file ad it is asking me to change it to different files but not the one i want
R is automatically generated, and you should never add or delete from this file.
I have faced this problem many times, and it mostly caused by xml file.
You should check your XML file carefully. It is most likely that you will find your answer there.
If your importing any library, make sure you're importing those file correctly.
R refers your res folder. You should have a subfolder in res called layout that contains your edit_item_layout.xml.
If you're receiving the error R cannot be resolved to a variable, you'll need to:
import your_package_name.R;
If you're receiving the error edit_item_layout cannot be resolved or is not a field, try:
Cleaning your project by selecting: Project --> Clean
Right clicking your project and selecting: Refresh
If you're R.java file is corrupted, because it's automatically generated you can also delete your gen folder and it should be replaced immediately.
Related
I have got a project (implementing Sceneform) that contain sfb files in the raw folder.
I want to copy/past these sfb files to another project. But when I paste them, the content is no more readable even if the file is ok in the 3D preview window.
How to copy/paste a .sfb file from one project to another ?
Ok, found the solution. You have to create a sampledata folder like explained here: https://developers.google.com/ar/develop/java/sceneform/import-assets
And copy/paste also all your sfa, fbx, bin, etc.. files here.
And then the text in the sfb file will become readable.
I have a java code that creates a kml file and then the front-end code wants to read the file right away. The file creation is successful. But the problem is I need to refresh the project folder from Eclipse and then it can read the file. This is very obvious to read the file in such way.
My question is how to read the file from front-end code without refreshing the project folder. Is there any techniques?
Thanks in advance......
I'm not sure what the exact error is you get, but it might help if you create an empty file before the process and just append stuff during execution. That way the file is found without refresh.
I found the solution for this problem. Just create an empty file as the same name that you used inside your code and then put
Thread.sleep(2000);
after the file creation method.
Pretty simple :-)
I am trying to install Oracle 11g in my laptop. Im downloading the setup files from here:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html
I have downloaded win64_11gR2_database_1of2.zip and win64_11gR2_database_2of2.zip.
I have put them in the same folder and started the setup file from the 1of2 folder. I go until certain steps and finally during installation i get WFMLRSVCApp.ear file not found popup.
I googled and i see some solutions where 1of2 and 2of2 file should be unzipped to same folder and then start setup. I did the same couple of times but still im getting the same error. Any anyone guess what is missing?
extract win64_11gR2_database_1of2.zip into win64_11gR2_database_1of2 folder first.
Then extract win64_11gR2_database_2of2.zip into win64_11gR2_database_2of2 folder.
copy all 4 files in database/ stage/ components folder in win64_11gR2_database_2of2 folder(unziped) & paste them (no replacement) in database/ stage/ components folder in win64_11gR2_database_1of2 (unziped).
Then run the setup again. I experienced in it. It works..
What you have to do is copy what is inside components folder ( i think four files ) in win64_11gR2_database_2of2.zip and paste it inside the win64_11gR2_database_1of2.zip components folder and re run the setup . it works
If you are installing the Oracle Identity Management 11gR2, you might receive the WFMLRSVCApp.ear file missing during Installation error during the database installation.
The way to resolve this error is:
Make sure you downloaded two disk
win64_11gR2_database_1of2.zip
win64_11gR2_database_2of2.zip
Steps:
Right click the win64_11gR2_database_1of2.zip file and select
Extract Here.
The software will extract in the folder named database as below,
You can see the following folders and files under database\stage, note the Date modifiedfor Components folder.
Do the same for win64_11gR2_database_2of2.zip file and click extract here, the extracted file will be placed in the same database folder
Now check the Date modified
That's it, now you can start by clicking setup.exe under database folder.
Hope it helps to understand easily.!!
I had the same problem but it's an easy one to solve: Download WinMerge and use it to merge the 2 folders that come out of the zip file from Oracle. That will do it.
http://winmerge.org/
1) Normally extract win64_11gR2_database_1of2.zip and win64_11gR2_database_2of2.zip
2) Copy directory
C:\Users\Fatality\Downloads\win64_11gR2_database_2of2\database\stage\Components (from extracted win64_11gR2_database_2of2 directory)
to
C:\Users\Fatality\Downloads\win64_11gR2_database_1of2\database\stage\Components (in extracted win64_11gR2_database_1of2 directory)
This question already has answers here:
"R cannot be resolved to a variable"? [duplicate]
(30 answers)
Closed 2 years ago.
I got all of this code from here
I am extremely new to all of this, and am having a few problems.
The error "R cannot be resolved to a variable" comes up on the bold parts of this code.
Resources r = context.getResources();
**setBackgroundColor(r.getColor(R.color.candidate_background));
mColorNormal = r.getColor(R.color.candidate_normal);
mColorRecommended = r.getColor(R.color.candidate_recommended);
mColorOther = r.getColor(R.color.candidate_other);
mVerticalPadding = r.getDimensionPixelSize(R.dimen.candidate_vertical_padding);**
mPaint = new Paint();
mPaint.setColor(mColorNormal);
mPaint.setAntiAlias(true);
**mPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_height));**
mPaint.setStrokeWidth(0);
The only thing I can think of is that I haven't copied and pasted everything correctly?
R is a Java class file that basically maintains an index of resources by assigning every resource that your application uses with an integer value for lookup. If you look in the res directory of the sample you're following, you'll see a values directory underneath it containing a colors.xml file that defines any custom colors. Note that in this specific example, you are using a color resource, not a Color State List resource as Paul had mentioned. Color state resources go in the color directory, but definitions of simple colors go in the values directory. Confusing, I know.
Resources in Android are defined via XML files. R.java is created automatically by the Android build process when these XML files are parsed. Different types of resources need to be placed in to specific directories for R to be structured properly; quite unhelpfully, not all of these directories are automatically created for you when you make a new project under an IDE.
Read this article about Application Resources, this article about providing resources, and this article about accessing resources (all Google documentation) for a bit of a better understanding.
Lastly, if you DO have all of your XML files in the proper place, check your import statements. Sometimes conflicts can arise if you have too many imports or if all of your imports aren't in place; if you're using the official Android Dev Tools in the form of the Eclipse plugin, the easiest way to handle imports is to use the Ctrl+Shift+O shortcut (Cmd+Shift+O on a Mac). If your imports are correct, and all of your XML files are in place, perform a rebuild on the project. If this still doesn't work and you are using Eclipse, I know that sometimes Resource resolution conflicts can inexplicably be fixed by simply closing Eclipse and launching it again.
R is an automatically generated file made from your resources.
Taken from Android docs
Color State List Resource
Define a color resources that changes
based on the View state. Saved
in res/color/ and accessed from the R.color class.
I would guess that the different R.color.candidate_* all need to be defined under res/color/
The R.java file should be automatically generated by Android. Try the following:
If you are using Eclipse try "project clean" to regenerate the file.
Use Ctrl-Shift-O to "reorganize" your imports. This will automatically add the R.java file to your imports if necessary.
Try to fix all errors not related to the R file and then retry the "project clean" and Ctrl-Shift-O option again. Other errors (e.g. typos in your xml layout files) can "stall" a new build of the R file via project clean.
Make sure your project is an Android project and you have an android.jar file on your classpath. If not fix this and retry step 1-3
you ned to copy the resources om the example you are using into the releavent directories in you res folder. The first word (after R.) is the directory you use.
so for R.color you put the resoruce in res/color in your project.
for the xample the resources are here:
http://developer.android.com/resources/samples/SoftKeyboard/res/index.html
they should also be in the version of the android SDK you downloaded:
ADKPATH/samples/android-/SoftKeyboard/
I got this error message many times. And mostly all of them were caused by some mistake in xml files or that I forgot to put 'check' in front of Build Automatically option. Try it! Maybe it will help You.
I used following code to access an image from "res" folder with NetBeans
imgWelcome = Image.createImage("/cover.png");
img = new ImageItem(null, imgWelcome, ImageItem.LAYOUT_CENTER, "");
Though the resource is not getting detected and i keep on getting NullPointerException. As weird as it sounds, exactly same technique worked in my previous program.
What am I doing wrong here?
P.S. I've double checked that the file exists in the res folder
There might be many reasons for this, but I have found that most of the time, it is due to how the project is built. Some build scripts include the resources in the res/ folder as top-level files, and some include that folder as a folder in the jar file.
What I have always done to troubleshoot is to rename the jar output to zip and look inside. If the image files are contained in a folder then you should address them as such.
Your code will not find cover.png if it is in the /res folder.
Inspect the contents of your jar using 7-Zip or similar, ensure the image really is in the /res folder, then replace the first line with imgWelcome = Image.createImage("/res/cover.png");.
Oh wow.. this was because .png was not supported by my emulator. And what all I tried :(