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

查看:112
本文介绍了局部变量或实例字段名称与正则表达式 '[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'
}

我试过 File 菜单 ->使缓存无效/重新启动,它没有帮助.我想解决问题而不是忽略警告.任何帮助深表感谢.谢谢.

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. 您可以通过从左上角的下拉菜单中选择所需的配置文件来更改检查配置文件

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

Disabling any unwanted inspection from the list.

创建您自己的检查员档案.

Creating your own inspector profile.

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

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