Android Studio not reflecting changes to images during export of APK - android

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.

Related

Android studio strange behaviour with some files appearing different than how they are

I have a problem with Android Studio that happened all of a sudden today when I opened AS.
As you may see in the pictures, some files are strange.
In this picture you may see that some of the .java files have different icon
And totally wrong content
Same thing happens with SOME of the XML files which have different content
Also some of the PNG images are not displayed in AS.
All files are ok, if for example I open them externally (notepad...) they are ok (luckily).
Is there a way to fix it?
I've already tried to invalidate cache/restart but it didnt work.
Thanks
So, it happened once again, but I've found a quick fix.
I post it as an answer so people can easily spot it.
Quick fix:
Go to the folder "C:\Users\"your user"
Rename the folder ".AndroidStudio3.2" in ".AndroidStudio3.2backup"(name is example)
Launch Android Studio, It will not find configuration files, so it will ask you if you want to import them from the folder ".AndroidStudio3.2backup"
Click yes, few seconds and now you can delete the backup folder cause it will be created another ".AndroidStudio3.2" folder. Notice that I've renamed the original folder instead of delete it for security, and so to avoid to reconfigure Andoid Studio again, but you can choose to start a new configuration if you want.
Once launched Android Studio, click import (gradle...) and import your project.
Everything worked fine after this few seconds quick fix.
Hope it helps.
In fact this problem has been reported to the Android Studio team already.
A workaround would be to delete the caches folder of the Android Studio directory:
C:\Users\USERNAME\.AndroidStudio3.3\system\caches
This at least is the recommendation from the issue tracker and worked for me as well.
The same happened to me when I updated the libraries in gradle kotlin, etc. what I did was to download my project from my version manager and update the libraries one by one and prove the project works.

How to refresh A Project in Eclipse

I have been studying Android on Eclipse Mars for some time and i have been facing a constant problem everyday-the changes made in a folder/file are not recognized by some other folder/file. For example, if i create a new layout in the layout folder and then use it in the setContentView, it shows me an error ("layout-name cannot be resolved or is not a field). It works if i save the project,close it, and open it again, but this takes up a lot of time if i have more than one error, so the question-is there a way to save and refresh the project (without having to close it) so that the newly made files and folders are recognized by the java files?
Thank you.
You can refresh your project in Eclipse by right clicking on the project root folder in your Project Explorer and selecting "Refresh".
You may also want to consider checking if you have "auto build project" turned on. In your top toolbar go to Project -> Build Automatically.
If build automatically is turned off you will have to manually build your project, by Right Clicking on the project in your Project Explorer and selecting "Build Project".
However, I do agree with Pankaj Nimgade that Android Studio is likely a better entry point IDE for Android development.
Real advice: Switch to Android Studio as soon as you can. There you would sometimes have another problem called "sync" though. But it's a much better IDE and you are at least in line with Google.
on Eclipse, F5 should do the trick. Or right click your project and Refresh. Or Clean all projects. If you are still stuck, simply close Eclipse and run it again.

Eclipse - Android drawable image resources not refreshing

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.

Messed up in Eclipse after viewing a sample project

I imported a sample 4.0.3 project and after deleting it from the Project Explorer list every thing is lost, now there are none of the projects that I was working before in Package Explorer??
Moreover now on importing these old project For Example name "On" are coming with the name "OnActivity" but still not able to run.
Else in workspace every file is ok, I tried to CLEAN but still no effect.
I'm new to devlopment kindly guide me.
Recover the source code from your workspace in the Windows file browser. If all attempts to recover fail, you can just create the projects from existing (recovered) code.
And what project are you trying to run? If APIDemo or QAActivity, the log shows you why you can't run them.
And instead of using the Play button (start) to launch, use the dropdown triangle and select the project to run, else the XML will be run (obviously that won't work).
Furthermore, make sure Eclipse knows it's a Android Project you're trying to run.

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