Eclipse - Android drawable image resources not refreshing - android

I'm using Eclipse (4.2.1 Juno) on Windows 7 for my Android 2.2 project. I have several PNG resources in my drawable folders, and I'm finding that if I edit my PNG files (Paint/Photoshop etc) Eclipse doesn't recognise the file has changed and the ADT graphical layout designer still displays the old version of the image. I've tried refreshing the project folders list, tried doing a Project->Clean but neither has any affect. The only way I've found of getting Eclipse to recognise the new image version is to exit completely and restart which is a pain.
Is there some setting I can use to tell Eclipse not to 'cache' the images and always read the latest version off disk?

Try in Eclipse Project -> Clean then select your project. This will delete your R.java file and will generate new one.

That is a common problem of Eclipse that it doesn't recognize external changes for files in the workspace. The only thing I have found out to remedy this problem a little (apart from refreshing like crazy), are the refresh settings in external tools configurations. That is, if you run for example an Ant build, you can tell eclipse to refresh the workspace or specific resources afterwards. I don't know of any automatic way to do this though.

you should try saving all the unsaved resources and files after adding images ,than try out again.try cleaning both options with cleaning your single working project and with cleaning all projects.

I don't know of an automatic setting, but I have found a relatively simple manual action that seems effective. I was having the same trouble as you; now the following procedure seems to work consistently for me, with Eclipse Juno 4.2.1.
Click on the "res" folder to select it, then press F5 to refresh. Also make sure your PNG file timestamps have been touched.

Resources cached in bin\res folder.
Create script which delete folder bin\res with all content.
Add this script as external tool in builder list.
Set position in builder list - after CDT builder. Second position in list. If no CDT builder - set it first.
Enjoy.

Related

Android Studio not reflecting changes to images during export of APK

I have a project i have worked on for a few weeks now. I went in to optimize some png's and was able to take a few mb's off the file size. However, when i generate the apk its the exact same file size.
I remember in eclipse i could go into the gen folder to delete those images and it would then recognize the new ones. I tried to go into the build folder in studio and do that but it still produces an apk the same file size. Is there something im missing?
I have taken one of the optimized images out of the produced apk and compared to the old and its the same size so its not picking up the new one for whatever reason.
Is there something else im supposed to do?
I know this is a very old thread but the answer to this question was never accepted.
So the problem here is in the emulator and not your computer or the software.
When you update the images the file names and paths stay the same. So it doesn't change the files on the emulator. I think it's just the way the android system works, if nothing changes then the app on the phone doesn't update.
So the solution is to simply uninstall the app from your emulator, then run the app from Android Studio.
Try rebuilding your app after refreshing the workspace, it works in eclipse but not sure about studio.
Go to Project->Clean. Uncheck "Start a build immediately". Go right click on your project and choose build. Then Run as - Android Application.
In IntellijIdea :
http://www.jetbrains.com/idea/webhelp/cleaning-system-cache.html
How to clean project cache in Intellij idea like Eclipse's clean?
For me it works to choose Build -> Rebuild Project on the main menu to do a full rebuild whenever I only change assets (i.e. when no source code has changed).
On top panel of xml designer there is Refresh Button.

Failed to create the part's controls

I get a null pointer exception opening about half of the android XML files in my layout directory. There seems to be no pattern to why some files open and some files don't.
I upgraded eclipse to Juno. Re-installed all the plugins (ADT), re-installed the android SDK. I brought in my old workspace and adjusted my projects to point at the new android SDK.
Stack
java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.setLocaleCombo(ConfigurationComposite.java:1566)
at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.syncRenderState(ConfigurationComposite.java:3049)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1158)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:679)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:359)
at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1081)
at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:607)
I found one way to resolve this. My eclipse recently crashed (and wouldn't start again) for an unrelated reason. To get it to start again I deleted most of the files in ${workspace}/.metadata/.plugins. These files regenerate (but will wipe some of your saved plugins and settings). Resolved my startup problem and my xml editor problem.
Just close all the xml files and restart your Eclipse SDK
An additional solution that worked for me and might work for others:
Create a new workspace and import your existing projects into it. I felt a little better about trying this than I did blowing away or moving my .plugins directory in the existing workspace. After I created the new workspace and imported the project that was giving me the cryptic "Failed to create parts controls" message, it worked fine. I'm pretty sure it's something bad in the .plugins or elsewhere in the old workspace, but I'll just keep using this new one until it starts to crap out on me.
Note that this can also happen if the containing folder contains too high a resolution
Example:
layout-sw500dp (this folder works okay)
layout-sw1000dp (this folder causes "Failed to create the part's controls" error)
I finally found out...
I had the problem even after deleting and setting a new copy of eclipse. The problem was because of the wrong Java version. You should find the right Java version for your eclipse.
In my case I have a project which uses Java 8 and for that I use eclipse Luna. But my other project which I develop it vie eclipse kepler uses java 6 (The project with the problem!).
Since Kepler and Java 8 are not compatible, I got this weird behavior from kepler. As soon as I ran Kepler via Java 6, everything was back to normal.
If you wanna know how to sets different Environment Variables and sets your Windows Path without setting up the Environment variable everytime for each project, let me know, I would be happy to share how to write a batch file to do that...

Eclipse projects sharing images?

I had an Android project in eclipse, I then duplicated the project changed some of the code and updated the images, in windows explorer and eclipse the images are updated but when I run the app it uses the images from the original project, not the copy but I want the two projects to use their own images.
Any Ideas? have I missed something I needed to update in the new project?
In the "Build" folder you may see temporary files to build the application. Eclipse does not always correctly updates them because attributes of files may be violated.
If "project cleaning" has not helped you may delete the "Build" folder from the project folder.

android eclipse driving me mad?

I've quite new to Android development and specially Eclipse.
I'm busy on a project called, say 'HelloEclipse'. I've had some major changes ahead, in which I had to some very big changes.
So I made a zip file of c:\workspace\HelloEclipse, placed that in a save place. Went on to work on my project. Few hours later, I wanted to go back to the saved situation. Closed Ecplise, rebooted my computer, because I wanted to make sure there were no locked files. Deleted the old c:\workspace\HelloEclipse folder, place the version out of the ZIP file back.
This resulted in a totally corrupted workspace status. Could not go foward, nor backward. I've ended up, creating a new project, and pasted in everything, took me hours. I think this is quite stupid Eclipse behavior. I've also tried ot, export/import with a archive from out of Eclipse, also not succesfull.
So the two questions;
How am I suppose to save projects (without installing anything like subversion)?
Why is saving the files not enough, and why does that make Eclipse barf?
Thanks in advance!
Dennis
In eclipse if you want to reimport an old project from a ZIP, don't just copy the project files to the workspace, instead, extract the files to a normal dir outside the workspace.
Open Eclipse normally and select File>New Project>Android Project, just as you would to to create a new Android project, but then in the new android project window, you have a radio button giving you the choice to Create project from existing source, point it to the directory where you have extracted your old project and it should be re-imported to the WorkSpace alright.
Or do File>Import>Import existing project into workspace.
But in any case, don't put the files in the workspace manually to avoid conflicts, Eclipse will copy the files it needs itself upon importing.
There are hidden workspace files that you may have missed -- specifically, .classpath and .project. That said, it's a lot easier to make a backup copy (for example, of a released version so you can continue developing while supporting the release) by simply right-clicking on the top-level of the project in Eclipse and selecting Copy, then right-clicking and selecting Paste. The result will be a copy of the project after an opportunity to name the copy.
If you want to zip projects, you can do that by exporting them. If you want to delete existing projects, you should do that from inside Eclipse with a right-click. You can import the zip you previously exported.
If by save, you meant backing up the best something would be to create a local repository. If I were you, I would backup my code in an online repository too; to save it from hardware crashes or other disasters.
In your problem, you could have tried deleting the project alone and import the backup copy(from the zipped file) instead of deleting the entire workspace. Can't pinpoint the exact reason of why eclipse barfed but maybe because it messed up the workspace settings for eclipse. On a related note, I found this on the net.
Eclipse is rather troublesome at times but AFAIK it's the best IDE for android.
First of all, after several months of developing with eclipse I moved to IntelliJ (they have a community edition) and I found it much much better.
In intelliJ you can save local history, for example, you can set-up a label and go back to that label whenever you like without losing anything.
As for eclipse, you probably didn't zip some hidden files or something.
In addition, I remember having some similar problem, I had to resync the files with the project, try this one
Good Luck
I do the same thing with my projects. Instead of going through windows explorer to copy the files, I find copying the entire project from within Eclipse (right click the project in the explorer window pane, click copy, then click outside of the project and click paste) works just fine. When you paste it, you can specify a new save location and project name, which can be your backup space. Then you can switch between versions of the project no problem.

Why does Android Eclipse constantly refresh external folders and take forver?

Just my a new Android phone and I've been tinkering with some basic apps. It's been driving my crazy that the Android plugin for Eclipse refreshes externals folders whenever I save ANYTHING. Normally I wouldn't mind but when it takes 10s to refresh I start to notice.
I already searched and other people have this problem, but there are no solutions.
If it matters, Eclipse 3.5 running on a 64bit jvm on Ubuntu 9.10
If you have references to external sources put them in a zip file:
YourProject->rightClick->Properties->Java Build Path->libraries->..., and then most notably android.jar, but other libs can be the culprit too. Expand it and and select Source attachment, and then (if it doesn't say 'None') press the 'Edit...'-button. If that points to a directory waht you should do is compress that source-directory into a zip file and make the source attachment point to that file.
Apparently eclipse/adt feels the need to refresh sources on the file-system. When they're in a zip-file it seems confident that they have not changed....
You could try disabling "Build automatically" from the Project menu.
First of all Eclipse has a cool feature called a Preferences menu which is located under the window menu located at the top of the screen. Inside there are all sorts settings for pretty much anything you could want to adjust, including the option to turn off Native file system hooks and polling (under General -> Workspace). This is the actual solution to your problem as disabling build automatically doesn't solve the external folders issue, as soon as you build your project it starts right back up with refreshing them. Just keep in mind that if you update your Android SDK at all you will probably need to right click on the root directory of your project and hit refresh after the update finishes.
Secondly, as far as Netbeans is concerned there are at least a half a dozen pages worth of forums posts and various methods for using the Android SDK with it that are also available through Google, I'd give it a look.
I generally do the above step of turning off Automatic build and also try to have not more then 1 open project in my project list.
I myself am fed up of Eclipse from this. Importing a big android project 'ALWAYS' hangs my eclipse and i have to force close it and restart it.
P.S. I really wish google would create an Android plugin for Netbeans =(

Categories

Resources