How to configure ktlint gradle plugin in a continuous mode? - android-studio

In my Android Studio app project, I've integrated ktlint gradle.
Is it possible to configure the ktlint gradle plugin, so that it runs continuously on the fly (while coding on the keyboard)?? Like ESlint is used for JS, it warns me immediately if any lint warnings occur..

It is not possible to do that. klint is not a static analysis tool.
Alternatively, you can write custom lint rules for the same. Here are some resources for doing so:
Android Dev summit 2018 talk
Android Dev summit 2019 talk
Android source code for standard lint rules
Repos
https://github.com/googlesamples/android-custom-lint-rules
https://github.com/tikurahul/lint-experiments
https://github.com/vanniktech/lint-rules

This is possible in Intellij / Android Studio if you install the ktlint IDEA plugin.
It's also configurable so you can represent findings as warnings or errors.

Related

Does it worth to use SonarLint in Android Studio or IntelliJ

IntelliJ IDEA and Android Studio have a Lint tool which is very useful. You can even call it from a CI pipeline to check your project's code.
Given that, I have two questions about this Lint and SolarLint:
Does SolarLint plug-in complement or add something new to the code analysis made by the built-in Lint tool in both IDEs when you want to inspect Kotlin code?
Does it worth to install the SolarLint plug-in if you don't use SonarQube? Does SolarLint impacts in the IDEs performance?
Thanks in advance.

The difference between running tests from AndroidStudio and gradle task

I have local tests which use mockito and powerMockito in my project. There are about 300 of them.
When I run them from the Android Studio (Run -> Run test configuration), all of them passed.
But our CI system launch it using gradle task testDebugUnitTest, which fails about 90 of them with different errors.
The question is: what is the difference between these mechanisms?
Are you using Android Gradle(https://developer.android.com/studio/releases/gradle-plugin.html) plugin?
One must be aware that Android Studio build system is based on Gradle, and the Android plugin for Gradle adds several features that are specific to building Android apps. Although the Android plugin is typically updated in lock-step with Android Studio, the plugin (and the rest of the Gradle system) can run independent of Android Studio and be updated separately.
Official docs here: https://developer.android.com/studio/releases/gradle-plugin.html
So, if there are version and platform related differences, we should expect the results to be different.
Hope this helps!

Running an IntelliJ-developed plugin in Android Studio

There's another thread about this topic here but with no accepted/sufficient answer. I am building a plugin targeted at Android Studio using IntelliJ Community Edition plugin development tools and I need to run and rebug the plugin in Android Studio. However when the run command is clicked in IntelliJ CE, it opens another instance of IntelliJ and opens the plugin in IntelliJ.
How can I change this configuration to run the plugin in Android Studio instead of IntelliJ? Upon researching, Android Studio plugins are developed using IntelliJ if I'm not mistaken (As mentioned here and here). There's no official guide addressing this. Any clarification and guides on getting this done?
EDIT
The duplicate thread does not solve the problem as it does not state a solution to run the plugin in Android Studio

How to add Google Play APK Expansion Library to android studio project?

I have so apps that use APK Expansion Files. I usually have build these apps with ant. But I want to add AdMob code to these apps and apparently there is no way to build an AdMob app from the command-line so I have to use Android Studio. I looked at these docs: http://developer.android.com/google/play/expansion-files.html and they do not tell me what magic incantation I need to use in my gradle file. Does anyone know?
Apparently there is no way to use APK Expansion Files if you are using Android Studio. (see https://code.google.com/p/android/issues/detail?id=173235) That kind of sucks. So I guess I go back to using Eclipse.

Android Studio: Change inspection profile for one specific module in project

I have several modules in Android Studio project, and I would like to change inspections settings for one of these modules. More precise, I want to turn off all Android-related inspections in one module, but leave all general Java inspections in place.
I need this because I have a not Android-specific Java library module, and that module uses java.util.Properties, and it's load method was implemented in Android API level 9. Since that library is not Andoid stuff, I have not specified Android API level at all, and Studio warns me about that.
It offers adding Android annotation to ignore that inspection, but adding Android dependency to turn off Android warning seems bad.
I can edit the settings to shitch that warning off, but I don't want to turn API level warnings in the whole project.
As I found, in settings you can specify inspection setting either globally or for whole project, not for specific module.
Is there a way to change inspections settings for one module, or do some hack around?
I am using Android Studio 1.3.2.
The Studio should automatically understand that the Java module has nothing with Android, and stopped Android inspections (but they were not disabled, though): I went fix something in the code, rebuilt it several times, and when I returned to warning line, it was clean.
So, I don't actually know what's going on,
but I got some recomendations, that should help:
Sync your Gradle project, it will try to rebuild the project. Some dependencies and settings will only resolve after Gradle will do something internal.
If Gradle will fail, there might be errors in code that ruins interspections. Try to solve them.
If your project history is stored in VCS, try checkout the latest clear version and sync project again.
Check changes in .iml files manually. For some reason, Studio sometimes does weirds edits there, and if I rollback some of them, Studio works better.
Actually you can disable particular inspections being made by Android Studio. However this needs to be on all projects you have in Android Studio, and cannot be done in all modules you are currently developing.
To disable android inspections on your projects follow these steps:
Click on the File menu and Select Settings
Expand the Editor root node select Inspections
There you will have all the inspections which Android Studio checks when building a project (image below). You can expand the Android node and check what you wish to remove from your inspections.
Hope this helps :)

Resources