局部变量或实例字段名称与正则表达式'[a-z] +'不匹配 [英] Local variable or instance field name doesn't match regex '[a-z]+'

查看:292
本文介绍了局部变量或实例字段名称与正则表达式'[a-z] +'不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将Android Studio升级到 2.1.2 后,当我将旧项目导入其中时,我的代码中充满了警告。警告是:

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'

以下是截图。

如果我将同一个类文件复制到另一个新项目,则没有警告。只有旧项目会显示这些警告。
这是我的build.gradle文件:

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.

推荐答案

您的检查配置文件已更改。您可以通过这种方式恢复它。

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


  1. 转到检查 (面部右下角) - > 配置检查文件 - >设置 - >编辑器 - >检查

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


  1. 您可以更改检查通过左上角的下拉菜单选择您想要的个人资料

从列表中禁用任何不需要的检查。

Disabling any unwanted inspection from the list.

创建自己的检查员配置文件。

Creating your own inspector profile.

这篇关于局部变量或实例字段名称与正则表达式'[a-z] +'不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆