In Android Studio there is the lint.xml configuration and ./idea/inspectionProfiles/.xml manageable via Settings => Editor => Inspections. I understand lint.xml is used by lint command line tool and the inspection profile is used by Android Studio IDE.
The official documentation is here. I also found this post How is lint integrated with IntelliJ inspections in Android Studio? and this post Android lint on command-line missing issue groups (versus options available in Android Studio).
This answer has a good example of lintOptions{ } block in build.gradle.
Yet there is some information missing.
Are numbers and names of the rules the same?
Is there a (simple) way to convert inspection profile to the lint.xml and vice versa?
Are they completely separated or are there cases when one is included in the other?
Which one is executed apart from cases metioned above (e.g. analysis on commit)?
I can sum up my research so far.
1.) Inspection Profile is extending lint.xml, so the number of lint.xml rules is smaller than the number of Inspection profile rules.
The current lint.xml ruleset can be found here.
2.) When you have defined a lint.xml, in your Android Studio you can go to File => Settings => Editor => Inspections and use the Manage => Import dropdown towards your lint.xml. This will set all rule outside lint.xml to be deactivated.
I don't know of any way for convert from InspectionProfile into lint.xml.
3.) See 1.), Inspection Profile is extending lint.xml.
4.) As Inspection Profile is locally used and inside Android Studio, it is executed during runtime in the editor and on commit when analysis is checked.
Your lint.xml is usually located in the project's root and submitted into SVN/GIT. Then your configuration server (Jenkins, QuickBuild etc.) can have a designated task to run this lint.xml and process its output.
Additional, helpful things:
You can run gradlew lint from the Terminal inside Android Studio. It will create a html page at /build/outputs/lint-results-debug.html or at any file position specified.
When you open a lint.xml file in your Android Studio editor, a lot of content assist is provided for the rules. Nevertheless there seems to be a gap in the rulesets, as e.g. Convert2Lambda is in the example lint.xml, but not in the official documentation.
Despite that it is generally a bad idea to put ./idea under version control, for team distibution you can submit your Inspection Profile at /.idea/inspectionProfiles/MyInspectionProfile.xml and put every other file inside /.idea on ignore. There is an article on this topic I cannot find anymore, but this solution works like a charm for my team.
Related
I have and Android Studio project I haven't opened in months, and when I look at some individual files there's warning and errors that appear (missing permissions, deprecated functions, etc.).
I want to see all these errors/warnings at once instead of having the navigate to each file to see if it contains any.
When I run Code > Inspect Code with an inspection scope of Whole project, all it returns are warnings about typos and unknown XML attributes:
However, when I run an inspection with a scope of an individual file, it returns errors that aren't in the whole project scope:
The Inspection Profile is the same same in each case: Project Default.
Am I doing something wrong, and is there a way to see all warnings/errors for the entire project?
Run code inspection on an entire project in Android Studio
Step 1:
Got to File>Settings>Plugins
Step 2:
Search for Plugin SonarLint and install it.
Step 3:
Right Click on your project directory and analyze it with sonarLint. You will get all the warnings, errors and code improvements.
Thank you.
I'm looking for some support and tips on how properly share the Kotlin formatting conventions in an Android project that is being opened in both Android Studio and IntelliJ IDEA by different team members. I'd like to force the usage of Kotlin coding conventions; and I'd like to avoid asking every developer in the team to change their settings in IDE configuration of the Code style.
So far I've been following 2 approaches:
Commit the .editorconfig file to the repository - but this file does not cover all the settings that we would like to share between developers and IDEs.
Commit the files that are located under .idea/codeStyles/ directory in the root folder of the project. This seems to cover the cases that were not handled by 1), but the Project.xml files seems to be altered every time when the project is opened in IntelliJ (if the Project.xml has been created in Android Studio, and I suspect vice versa as well).
Moreover, I can see some inconsistencies when I try to format the same Kotlin source file in Android Studio and IntelliJ. Could it be that both IDEs contain different sets of rules of Kotlin official coding conventions?
Another way to share formatting options is via code style xml.
After you set all the options in your IDEa (in Editor -> Code Style -> Kotlin), click gear button next to Scheme and choose Export -> IntelliJ IDEA code style XML like shown on a picture:
Share this file with your colleagues, and they can import those settings in a similar way by clicking Import Scheme.... Since Android Studio is based on IntelliJ IDEa, it will understand this file.
In Android Studio v2.2.2, Code Cleanup feature available under Analyze option.
Analyze >> Code Cleanup
What this option exactly do with code ?
Please explain in details.
When you clean up your code using 'Android Studio', It start inspecting code defined rules.
For list of defined rules check, File -> Settings -> Editor -> Inspection.
(For Mac, Android Studio -> Preferences -> Editor -> Inspection)
Here you can find all rules like,
non-used variables,
non-used import,
Abstaraction issues,
Code style issues,
Java Beans issues etc.
After inspection of code, Android Studio will remove such code from your files that is not necessary. It is called cleaning up code.
There are many plugins available for it. As Android Studio support by default, You can format and clean your code using this feature.
If I change some code, save, and Run, it runs the last version of the program, not what I just saved. The only way I can make it update is if I Clean the project, Build the project, and then Run the project. Is there some way to avoid this tedium?
I spent some time create two dummy projects (one Android and one Java) and have a play with it, and finally come up with a workaround which is not used very often but able to solve your requirements.
First, I will explain your question a bit more (based on my understanding and what I have tried) so that other people can have a more clear understand about what is happened here.
According to the conversation in comments:
could you tell me what you have in following setting: project->properties->Builder ? – Sudar Nimalan
#SudarNimalan: I am not sure this is what you are asking, but: there's text that says "Configure the builders for this project", and under it is a single option, "Java builder", which is selected (checked). – shino
for android project, there should be, "Android Resource Manager", "Android Pre Compiler", "Java Builder", "Android Package Builder" in this order, chould you add those and try? – Sudar Nimalan
#SudarNimalan: I owe you an apology; I do have those four components. My "project" is split into 4 projects - "core", "core-android", "core-desktop", and "core-html". It's a little weird because I set it up with the libGDX project setup UI, and I was looking at the 'core' project when I answered your question. My 'core-android' project has all four (in that order), and it is the one that has the problem in my question. – shino
Scenario:
You have 4 project:
core: a regular java project (common pure java code here)
core-android: an Android application project.
core-desktop: not related to question so ignored.
core-html: not related to question so ignored.
The core-android project has dependency on core project, by adding core to core-android's build path (Properties -> Java Build Path -> Projects -> Add ...) and export list (Properties -> Java Build Path -> Order and Export).
Problem (Not Really):
Change some code in core and save it, run core-android, eclipse install last compiled apk, not the new one with change.
Reason:
The is the expected behavior, the way you used to reference core project in core-android only create a weak link (or something sort of) between core and core-android, the core-andorid's auto-build script doesn't aware any changes made in core. You have to clean the project (only need clean core-android project) so that Eclipse can delete the existing apk (under bin directory) and re-generate the apk (with the latest code changes from core).
See Xav's comments below, Android SDK tools should aware changes from plain Java project under project build path, and it does not behaviour this feature normally at the moment.
Note that if core is an Android Library project, then there is no problem and your core-android project will aware any changes in core project (java code, android resource and etc), if core is only used in core-android, this could also be a workaround: turn Java project core into Android library project.
Workaround (Eclipse Link Source):
There is another way (not commonly used) for adding soft link between projects:
First, you need remove core project from core-android's build path, this will also remove it from Export and Order list.
Right click core-android, choose Build Path -> Link Source ... Add ../core/src as Linked Folder Location and src-lib1 as Folder Name,see screen screen in the end.
This create a symbolic link src-lib1 under core-android in Package Explorer windows point to core's src foder, in the file system, you still have two separate project folder. Now if you change some code in core and run core-android, Eclipse will build and install latest apk. No need to clean core-android project.
Link Source Window:
Final look in Package Explorer:
You should always consider the normal approach as first option, after all, manual clean project is not a big deal compare to the unusual approach I described above.
Please follow this steps..
1. Project--> Build Automatically been checked??
2. Please following setting: project->properties->Builder like that?
Check below image.
And Also Check Below Settings.
Also Check Below Image
IF problem continues then please Update your ADT & SDK.
Hope it works for you .
Navigate to Windows->Preferences->Android->Build. Make sure that the checkbox "Skip packaging and dexing..." is NOT checked.
The Problem is the In your Eclipse, go to Project Properties - Builder, There is one CheckBox with AndroidPackageBuilder that is required to be Checked True. Now everytime you will do any changes in you project that will be reflected in your build and the Compiler will never say that
"Application Already Deployed, No need to Reinstall"
This will work evenif you dont have selected Build Automatically, Because everytime you run by clicking Run icon or Ctrl+F11 that will first Build the Project and Then Run it. So The requirement is just to Enable the Android Package Builder
You won't believe how easy and silly is the solution
On Eclipse,
go to Window-Prefences->run/debug ->launching
And then, on Save required dirty editors before launching :
choose the Prompt option,
Apply and OK
Basically, I need help importing downloaded source or creating a project from sample source programs. I'm looking for step by step instructions for both if anyone can point me there or post the steps.
I'm very new to Android/Eclipse. I have the environments installed and have successfully written a very minor app that works on the emulator and my real Droid X. I cannot, however, get any of the Android samples into a project without errors. I've tried importing, creating from existing source, and etcetera and it's all a mess with errors everywhere.
I have, however, successfully created a new empty project, then brought the components into the project one at a time typing or pasting in code for every file. I'd hover over and import Android and other components as needed. The WiktionarySimple, for example, ran with only a couple of changes and several warnings that I left alone. (I had to add 'formatted="false" in the statements below...)
<string name="template_user_agent" formatted="false">"%s/%s (Linux; Android)"</string>
<string name="template_wotd_title" formatted="false">"Wiktionary:Word of the day/%s %s"</string>
But there has to be an easier way to import! I've done the intuitive and I've followed instructions that I've found, but to no avail. Can anyone give me a complete list as to how to import or create a project from existing source or from source I've downloaded from the web?
Step #1: Start a new Android project
Step #2: In the first page of the Android project wizard, choose the "Create project from existing source" radio button, then click the Browse button and find the directory containing the project
Step #3: Tweak settings to suit, then press Finish
Step #4: If needed (not sure if it is anymore), right-click over the project name, and choose Build Path > Configure Build Path from the context menu, and make sure the Android entry in the checklist is checked
Its quite possible that you are not importing these projects incorrectly and that you are simply running into common problems that occur when importing projects.
For instance your problem involving adding formatted="false" is quite common and due to a change in the strictness of aapt, which is explained in this question. It is likely that the sample project was created before the change and has not been updated since.
That error involving the formatted="false" can also cause many more errors, since any xml after that error is often not parsed and thus any resources declared after it are not known. So the error No resource found that matches the given name (at 'hint' with value '#string/search_hint') and others like it are often due to the formatted="false" error. I would suggest fixing all the % sign errors with the formatted="false" then letting it rebuild and see how many errors are left.
As for the String types not allowed (at 'layout_width' with value 'match_parent') a quick search on stackoverflow says that its caused because FILL_PARENT was replaced with MATCH_PARENT in Android 2.2. So you need to set your sdk for the project to be Android 2.2 or higher. Here is the link to that question as well.
This happened to me in importing the wiktionary sample and i found the solution.
Import the project through existing code
Right click project and choose properties
In 'Android' Tab the default choice is the minimum API. Changed it to the latest(highest API)
Click ok.
Clean and build your project and errors will be gone
(probably optional)
6. Change the target and Minimum SDK in the Android Manifest