Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local variable or instance field name doesn't match regex '[a-z]+'

After upgrading Android studio to 2.1.2, my code is littered with warnings when I imported my old project into it. The warnings are :

Instance field name doesn't match regex '[a-z]+'
Local variable name doesn't match regex '[a-z]+'
Instance field access is not qualified with 'this'

Here's the screenshot.

Local variable or instance field name doesn't match regex '[a-z]+'

If I copy this same class file to another new project, there are no warnings. Only old project shows these warnings. Here's my build.gradle file:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 10
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.1.0'
    compile 'com.android.support:design:24.1.0'
    androidTestCompile 'junit:junit:4.12'
}

I tried File menu -> Invalidate caches / Restart, it didn't help. I would like to solve the problem instead of ignoring the warnings. Any help is much appreciated. Thank you.

like image 628
Yogesh Umesh Vaity Avatar asked Aug 15 '16 08:08

Yogesh Umesh Vaity


1 Answers

Your Inspection profile has been changed. You can restore that in this manner.

  1. Go to Inspections (the face bottom right corner) -> Configure Inspections or File -> Settings -> Editor -> Inspections

enter image description here

  1. You can change the inspection profile by selecting the profile you want from the drop down menu on top left corner

or

Disabling any unwanted inspection from the list.

or

Creating your own inspector profile.

enter image description here

like image 85
Supun Wijerathne Avatar answered Oct 22 '22 06:10

Supun Wijerathne