check whether image is used or not in a project - java

i am new to android. In the project most of the images are used, for some reason some of the images are not used.
But all the images are present in the res/drawable's folder. Going through the code to find which images are not used is a time consuming.
How could i check which images had not used anywhere in the project and remove it.
Solution with reference link could be better.

If you are using Eclipse you can run Lint Error Checking to know which files are used and which ones aren't.
Go to Window->Preferences->Android->Lint Error Checking
If you do any change in the list of enabled checks and click Apply you will be asked if you want to run lint. Click Yes and all the files that you aren't using will be marked with a warning.

Android Lint will do this for you. Check out Lint Tool - I guess, it otherwise depends on which IDE you're using. I know that IntelliJ will mark unused items in the main R.java file itself. But afaik, Eclipse doesn't do this.
Best bet is to use Lint. You can run it from command line also, so doesn't matter what IDE you're using.

Related

IntelliJ Debugger catching wrong file with same name

I have two files with same name in two separate packages package1 and package2 in same maven project. I added a debug point at line i in the file that is present in package1. But while debugging, the IntelliJ IDEA debugger stops at line i of the file present in package2. This has been occurring with a few of my fellow mates as well. Is there any such bug reported with IntelliJ ? Any fix or workaround ?
You can turn on Show alternative source switcher flag under Settings >> Build, Execution, Deployment >> Debugger.
Check show alternative source switcher check box, and IntelliJ IDEA will allow you to change required file.
Now, when you are debugging, IntelliJ IDEA should provide you other options to chose among source files.
To add on to the accepted answer, if you already have the setting checked but the alternative source switcher is not showing up, I found that toggling the setting off and back on bring the switcher up. On IDEA 2022.1.

IntelliJ IDEA 12 duplicate class R.java and BuildConfig.java

I use Eclipse for android development and trying to use IntelliJ. I have successfully run the application once. But now, I couldn't seem to rebuild the example Hello World application. What am I missing here? The R.java is not rebuilding anymore. Here is a screenshot of the errors.
And here is my setting
This happened to me because I've marked source folders incorrectly.
Under project settings once you click on particular module, Just check whether you have Mark any additional folders as source folders.
Check the screenshot, By default it should be something like below, All mark as buttons should be unchecked
By mistake I've checked Mark as: "Source" button and I got this error. Just uncheck it.
R and BuildConfig are autogenerated by the android build system. Maybe you somehow copied an autogenerated version of your eclipse project into the idea project and then idea generated second ones. By default, idea will use a folder called gen for these files which is marked as a source folder. Make sure there are no other source folder containings these files.
You can quickly find classes by pressing Ctrl+N and starting to type the name of the class. If you find duplicate results, delete any of them and let idea regenerate the correct ones.
Unfortunately you may not like my answer, but my project is due yesterday and I don't have time to check every setting to fix the issue.
The way I resolved it is to re-create a new project, only copying the src, res, lib etc across. This was painfully difficult and presents other issues (manifest files and run/debug configs) , but proved relatively short as opposed to creating a new project ANYWAY and sifting through build options that may or may not be valid.
I encountered the problem while trying to add the KSOAP2 libs to the IDEA project, and although KSOAP has nothing to do with the problem, I may have imported them in the incorrect manner the first time and created extra self referential dependancies. This makes the most sense, but trying to figure out how to undo it would be next to impossible.
you can try to delete the r and buildconfig files from the com/x/x folder under android -> java
that fixed it for me.

Java: Missing libraries

I'm a bit new to Java / Processing and I opened up a project/workspace with the following errors:
is missing required library: '/Applications/Processing.app/Contents/Resources/Java/libraries/javamail/smtp.jar'
/javamail/dsn.jar
/javamail/mailapi.jar
/javamail/pop3.jar
I have the Processing app installed, but it's been a while...do I just need to upgrade processing or is there another place I need to go to get these .jar files?
I'm using Eclipse and there seems to be quite a list of referenced jar files (some broken)
It's telling you that there used to be a library at
/Applications/Processing.app/Contents/Resources/Java/libraries/javamail/smtp.jar
but it's no longer there, or possibly you opened a project that somebody else edited on a different machine where things were laid out differently.
Open the project build-path dialog and make sure all the libraries point to the correct locations.
If the problem still persist, try doing clean and build in eclipse. It might help.

Eclipse - Project contains error(s) but none seen

My project has been running fine for weeks. I went to swap out an image today and suddenly eclipse highlighted my project saying it contained errors but did not point to any particular files. I then cleans the project and now it is bringing up the message
R cannot be resolved to a variable
The gen folder is empty and I have these errors now over all my src folder. Does anyone know what to do?
All help appreciated.
Your project has an error and can not build thats why Android compiler can not generate the R class and eclipse warns you about that class. Check out all problems in the problems view. Also check project runtime and library settings if there is anything missing. You might accidentaly delete a lib or java runtime might have been changed.
When I encounter this king of 'weird' issues with *.xml resources I add one more item. I case of strings.xml I add new item and that CTRL+S the project will be rebuild and the R class will be refreshed. This usually fix the problems, and afterwards I delete the item that I added.
There are a lot of times when eclipese doesn't rebuild until you add something new (that it , until you make a change in your resources)
I hope this will help you if not , it might help to someone else having similar problems
If you did not disable the built-in Source history in Eclipse (right click on a file in Explorer view, then select Replace With -> Local History), revert to the code prior to your change, and rebuild. If it builds, figure out what the change was and adjust accordingly.
If you don't have that history, try to remember from memory. Likely it can't build the R file because one of your XML resource file is incorrect or references the wrong file.

Eclipse won't check for errors in my code (Java EE)

I have been trying to use Spring in my Java EE projects and while everything will compile just fine for some reason Eclipse just refuses to do any sort of live error checking like it normally does. you know like underlining a line of code that is totally wrong for ex:
System.BananaBoat.SetSail();
Obviously this class doesn't exist but Eclipse isn't throwing any sort of error at all. It just lets me do it. Is there something I need to enable to make sure that this is getting tested? Is this related to the incremental compiler?
Any insight on this would be great. Feels like being back in the stone age without this.
Check if the project has any problems in the "problems" fast view. Sometimes, Eclipse refuses to build automatically if there is a problem such as a cyclic module dependency, or some required .class file being referenced indirectly.
Here are some links:
Eclipse Problems View not showing Errors anymore
Best Practices for Eclipse's Problems View
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.user/concepts/cprbview.htm
Make sure that the automatic build isn't turned off.
I found this answer somewhere else.. Anywho, make sure your files are under the "src" file under your project, I had mine in another folder, for some reason eclipse will refuse to error-check in a place other than the src folder.

Categories

Resources