How to disable code inspection errors in README.md file in Android Studio
Asked Answered
S

5

7

In my GitHub README.md file, which is in the root of my Android project, I have code snippets like the following ones:

```xml
android:windowSoftInputMode="stateHidden"
```

```java
MongolToast.makeText(getApplicationContext(), "ᠰᠠᠢᠨ ᠪᠠᠢᠨ᠎ᠠ ᠤᠤ︖", MongolToast.LENGTH_LONG).show();
```

However, in Android Studio these code snippets give errors

enter image description here

I don't want to be warned of supposed code errors in the README file. How do I disable all errors here?

Notes:

  • I know how to suppress inspections normally in code with @SuppressLint or going into settings and unchecking the lint inspection. I don't want these errors to be suppressed in other areas of my project, though.
  • Somewhat similar question (without an answer): Android Studio - disable errors highlighting for excluded files
Siberia answered 6/9, 2018 at 1:27 Comment(0)
O
5

After doing some further research I come to conclusion that these errors are not from Android Studio itself but there are plugins for markdown format like Markdown Navigator and Markdown Support if any of them is installed and enabled then you will see above errors in README.md file.

I think this spell check is built in feature of these plugins and can not be controlled from Android Studio.

One option what I think is to disable these plugins and you are good to go.

You can disable these plugins from (Android Studio 3.1.4 MacOS) Preferences > Plugins (or File > Settings > Plugins in Linux) by unchecking them and restart (don't forget it) your Android Studio:

enter image description here

Osteogenesis answered 6/9, 2018 at 1:58 Comment(4)
For whatever help the plugin gave, I much prefer disabling it and not having the errors.Siberia
@Siberia this is the only option to get rid of those errors in markdown file. As I suspected rusito23's solution works only for non-markdown files only.Osteogenesis
The new version of Android studio preinstalled plugin "Markdown" as default that shows errors, too. The only option is to uncheck the plugin.Betsybetta
What a piece of garbage... Unbelievable...Related
M
3

Newer versions of Android Studio starting with 2022.2.1 Flamingo (at least from Beta 1) have an option to toggle "Show problems in code fences" under Preferences > Languages & Frameworks > Markdown.

Note that this toggles all problem types at the same time (typos, warnings and errors).

enter image description here

Merkle answered 13/2, 2023 at 21:9 Comment(0)
E
2

First you need to create a scope (Settings->Scope) and add the files you want to keep out of scope for the Lints you wanna suppress.

Then go to Settings->Inspections, chose the inspection you wanna remove, and then on the right choose from the drop down your scope to define the wanted behavior.

scope_behavior

In this case, my scope is called AVOID_LINTS, and won't show any typo warnings.

EDIT

In the first step, when you create the scope, you need to add your README to the new scope.

EDIT2

Where to find the scopes: enter image description here

You may search for the files you want to add, select and click include.

Easley answered 6/9, 2018 at 1:43 Comment(6)
OP needs only for README file. Your answer will avoid lints for whole project.Osteogenesis
Maybe first paragraph wasn't clear. In your new scope you need to ADD the README.md. Then continue with the steps. Fixing the answer now. Tx!Easley
did you test it? I am not able to find Scope in Android studio settings? Which version you are using?Osteogenesis
Yes and I use this config too. I use Android Studio 3.1.3 on macOS. Maybe using the search bar you will find it. (Settings->Appearance and Behavior->Scopes)Easley
I tried exactly what you have mentioned but somehow it is not working for me in case of README.md file, either I am not doing it correctly or this solution works for non-markdown files (I maybe wrong). As per my understanding those errors are coming from Markdown plugin. Please check my answer.Osteogenesis
Think you are right, I don’t use md plugin really. Works for other files tho.Easley
C
0

Remove code type annotation, change from:

```xml
android:windowSoftInputMode="stateHidden"
```

```java
MongolToast.makeText(getApplicationContext(), "ᠰᠠᠢᠨ ᠪᠠᠢᠨ᠎ᠠ ᠤᠤ︖", MongolToast.LENGTH_LONG).show();
```

change to:

```
android:windowSoftInputMode="stateHidden"
```

```
MongolToast.makeText(getApplicationContext(), "ᠰᠠᠢᠨ ᠪᠠᠢᠨ᠎ᠠ ᠤᠤ︖", MongolToast.LENGTH_LONG).show();
```
Chafer answered 10/2, 2023 at 16:57 Comment(0)
N
0

Before:

enter image description here

In android studio go to:

Settings -> Languages & Frameworks -> Markdown

untick Inject languages in code fences

enter image description here

After:

enter image description here

Notable answered 3/11, 2023 at 19:57 Comment(4)
The question is about how to disable inspection errors, not disable all language features. And a very similar answer doing that has already been provided.Narvaez
I have edited the answer again. Please try it now. I hve given the answer according to the question. Language inspection will not work only in marksheet.Notable
But this does not just disable inspection. It disables all language features, including highlighting and code completion. The answer I linked to above does what the question asks: it only disables code inspection errors. You can see the checkbox right in your own screenshot.Narvaez
Ok @Narvaez you are right at this point and i think there is solution for this point till now.Notable

© 2022 - 2024 — McMap. All rights reserved.