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

2

10

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.

Mattiematting answered 24/11, 2015 at 10:46 Comment(0)
M
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:

  1. Sync your Gradle project, it will try to rebuild the project. Some dependencies and settings will only resolve after Gradle will do something internal.
  2. If Gradle will fail, there might be errors in code that ruins interspections. Try to solve them.
  3. If your project history is stored in VCS, try checkout the latest clear version and sync project again.
  4. 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.
Mattiematting answered 4/12, 2015 at 13:21 Comment(0)
T
0

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:

  1. Click on the File menu and Select Settings
  2. 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.

Inspection Window in Android Studio

Hope this helps :)

Turn answered 27/11, 2015 at 14:55 Comment(5)
I knew that way. The question is how to turn if off for module.Mattiematting
I don't know if there is a way how to turn it off per moduleTurn
Well obviously there is not.Wallet
@LapshinDmitry can I be of any help to you in any other way?Turn
@codedByMi looks like Studio figured that it's wrong about this inspection: there is no warning right now. Will look further.Mattiematting

© 2022 - 2024 — McMap. All rights reserved.