I want to do clean up my project which having 1000+ Java classes, but many of them are not in used. Is there easiest way to track unused classes and xmls.
You can analyze your whole project to find XML, code and all things that are unused or not required with Lint
With this you can find unused classes, resources, security leaks,
refactor suggestions and more, it's really useful.
First right click on your project main package, select Analyze - Inspect Code.
After that select whole project
Then you can see all your problems to fix
An example of an XML error, you can see the errors from the drop down and in the right where they are located, and also you can fix all this problems from the same inspector, above you can see suppress, that is a way to fix this, and you move on to all project problems with this
Also, you can remove unwanted resources like this, right click in your project structure
you can select preview and see all the resources which you can delete
Refactor - Remove unused Resources...
Related
I have two android projects. One is the login and membership screen and the other is my main project. I did both separately, in case it would be okay to combine them later, but I realized that I made a big mistake. When I tried to combine the two, it started giving errors all the time and I couldn't do it. Gradle files were probably missing, but I'm very confused. Can anyone help me how to do it easily?
Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found
There is currently no easy option to "combine" two projects like to merge them without exceptions. But you can do the following:
The easiest way to combine two projects is to take the smaller project and copy all the files in /java /layout /drawable to the other project.
Then I would look up all files in /values and copy the values if you changed them.
After that you should look at the Mainfest and see wether you made changes there and transfer them. This will make most of the errors not come up because you just copied all the classes.
If you get the error anyway then go to your gradle files (build.gradle for project and module and settings.gradle if you use android studio bumblebee or newer) and check if there is any plugin or line you have in one project and not in the other and then add that accordingly.
I am in the process of doing clean up on a project that has gone through much of the dev cycle and is almost ready to go to production. I wanted to remove any unneeded PackageReferences in the the csproj but can not seem to find any way to detect them, except to perhaps to remove each one individually and try building... is there an easy way to see which of the PackageReferenceare actually needed for your project?
You can use Visual Studio Extension: ResolveUR - Resolve Unused References or use Resharper if you have installed it.
I've run SonarQube analysis on my Android/Java project and it resulted, among others, with issues:
Sections of code should not be "commented out"
If SonarQube is able to identify them, is it possible to automatically commented out code in Android Studio? I can't just remove all comments, because there are also some that are legit.
I have 500+ of them and don't want to do it manually. Any ideas?
There is no general solution for issues reported by SonarQube since SonarQube only finds problems, it doesn't offer a way to fix them.
In this particular case of commented out code, the same check is available directly in IntelliJ.
from the menu, select "Code | Analyze Code | Run Inspection by Name"
type "commented" to select the inspection about commented code
run it on the whole project
This inspection now lists the occurrences, and the Problems tool window offers you to fix all of them at once.
Following some links here I tried to rename a project. I went to c:\path\to\AndroidStudioProject and renamed the folder there, then found the .idea file and changed that. Now the project loads but java files are missing! However, on clicking java (in the bar at the top), then com I can see them each with a small red j.
I then looked in module Gradle build where there were 3 files, one with the new name and 2 older ones which stated that they did not belong so I deleted them, copying the compile info into the new one. Naturally on doing a Sync Now I get a bunch of errors.
Why does this have to be such a complex operation? Can anyone assist?
After you rename the folder, open the project in Android Studio. From there, right click something that needs to be renamed (e.g., module, package names, etc.) and use Refactor->Rename from the context menu. Keep doing this until everything that can be refactored is.
You will need to manually change the value of applicationId in the app-level build.gradle. Obviously, things like #string/app_name will also have to be changed manually. I recommend making these manual adjustments from inside Android Studio rather than directly editing the files. That way you'll know immediately if you break something.
My application is divided into several modules(dlls). The threads in the application will go through different modules (dlls). If I change a run time error check (for Eg: /RTCs) in one work space (module), should I change this in all work spaces of the dlls that the application uses?
Thanks!
Looking at the documentation all of them seem to only have local effects, so there is no reason they would have to be matched in all the projects. However as they will only reveal problems in those modules where they are enabled, you probably want to set them in all modules in debug configuration (they are incompatible with optimizations).
Note, that the easiest way to set the same options for all projects is to use the "property sheets" feature. It's hard to discover—you have to open the "Property Manager" window from "View" menu to find it.