Very strange error when importing images to Eclipse - android

I found a very strange and anoying bug.
Im developing in Eclipse, i use several images for my app.
Sometimes when i import a new image to the project and use it somewhere in my app, after the test run all the images are went to another places... Its like every image has changed their resource ID and they are all moved to another places... background loads for buttons, button image loads for scrollbars.. etc... every image is bugged and appear in random places!
Nothing can solve this bug, except deleting my app manually, then run again.
I work on my phone, not Emulator.
It is really annoying, i dont want in the future that when im updating in market, the users will get a messed up app...
Anybody know something about this?

That's probably because the R.java is messed up.. try to do Project->Clean and see if that solves the problem

If you are importing any image make sure that the name of the images in not in Capital letter and also its name doesn't start with any numeric value. Otherwise its going to create problem in generating its id in R.java.

Related

Is it me? Or android studio changed my whole build.gradle codes now my whole project is messed up now?

I was coding my android program on Android Studio and I made quite a progress on it. I remember I copied all the codes in my colors.xml (ctrl+A) when this happened. I was thinking to change the background image of my app so I deleted my background image in my drawable folder unchecking the "safe delete" option.
When the background image was deleted, I put another image using batch drawable import hoping that it would exchange the background image of my app, but it didn't. I tried to change the background image by linking the image in my code in the layout folder, same results. So I thought I could invalidate caches and restart hoping to fix the problem.
To my surprise my whole project was a mess, the errors where from my build gradle, all of the codes were changed! It was replaced by the codes used in the colors.xml
Now I can't do anything, I think I'm going to redo the whole project now but it'll take quite the time. So I'm asking here why it happened, or is there any possible solution as to I could recover my project codes? Thanks!
is there any possible solution as to I could recover my project codes?
Yes. You have few options to recover your project. One option is revert your project code which I normally do.
Right click app ---> Local History ---> Show History
Then you can select which file or time you want to revert.

How to change an image name in Android Studio

I got an app and there is this tiny error about the image name. The name is 'bg.png.png' which was allowed in Eclipse but not in Android Studio. If I fix it, I get 100 errors regarding 'Error retrieving parent for item'.
By the way I am using appcompat7 too. So I don't know how to fix and where this images is called in the code because the code is huge and I am not very good at android.
Select the image and press Shift+F6 (OR Right-click->Refactor->Rename). This will start the refactoring of selected image name. change the name to a valid one while highlghted and hit Enter. It will get renamed in all referenced places. Will prompt for confirmation so you have a chance to cancel if you feel it is not refactoring correctly. But it works just fine so you need not worry.

Android Error or Bug Idk?

ok so here's the problem in eclipse I am making a metric to standard and back calculator but I keep getting errors and I had to delete one of my layouts and remake it but now when I remake it it brings up the old layout and I am so confused and now when I try to edit it and save it I get this as a popup message:
title:Update Conflict
message:The file '/TemperatureConverter/res/layout/measurement.xml' has been changed on the filesystem. Do you want to override changes made on the file system?
What do I do to fix this?
I got it I just had to do allot of deleting and cleaning... sorry for wasting your time guys

Issue with batching the project

I'm trying to create an icon for our Android app. The png is created and was put into the proper folder of my project so it can be batched with the batch file. Up to now, everything was fine, but I did a new image I wanted to test on the emulator, but now, although the image is in the appropriate folder and my batch file configured correctly (it works for our 2 other identical projects), it won't take the new image and the previous one I tested keeps being batched despite being deleted (the .apk and key generated with the previous image were deleted as well) and also the app was removed from the emulator. Any ideas what could cause this? Also for some odd reason (I haven't touched the code of the project for well over a week), I ended up with this error "LanguageURL cannot be resolved or is not a field", I managed to fix it by copying the same line from the same project. Would that have anything to do with it?
Thanks for the help
Happened to me before... Are you sure the icon fits the specs?
Look here: http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html

Refresh list of drawables in Eclipse?

When I add drawable resources to my project they do not show up in the list of drawables in the Reference Chooser. I checked the R file and there are references for the files.
I have tried refreshing the project, cleaning the project, and fixing project properties and nothing seems to help. Sometimes a couple will randomly show up in there, but not all of them.
The only consistent way I can get them to show up is to restart Eclipse.
Any ideas?
Thanks
Edit: Further findings:
After some trials, I found an other inconvenient work around to he issue. Turns out when importing multiple files into the project at once, Eclipse will only add the last one imported into the reference chooser. So when I imported my images one at a time, they all show up properly!
Like I said, inconvenient considering the amount of images I have left to import, but maybe with this new information it may help nail down where the issue may be and a possible fix.
I too faced the same problem. I added an image to the res/drawable-hdpi folder, cleaned the project and was able to see the name of the image in the left pane in Eclipse. But when I tried to use this image using Reference Chooser and looked under Drawable, I didn't find it.
I simply exited from Eclipse, and started it again. It was there! Like many things in computers, problems can be resolved simply by restarting!
The only way I found to fix this is to include the generated R class itself.
I found out some new info again.
Since I am doing a port from Blackberry, almost all of my images' filenames have uppercase letters in them, so I end up importing them all and then having to rename all the images after they are imported into the project.
I tried renaming all of my images before importing them all into the project. To my delight, all of the images showed up right away in the reference chooser! So it seems there is a problem when you import files and they cause errors with your project and allowing all of them to show up in the reference chooser.
So if you have to rename files, do it before import!
I'm just not entirely sure that this is the only cause for this issue but it has solved the problem for me.

Categories

Resources