android - 局部变量或实例字段名称与正则表达式不匹配 '[a-z]+'

标签 android regex android-studio intellij-idea gradle

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

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'

这是屏幕截图。

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

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

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'
}

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

最佳答案

您的检查资料已更改。您可以通过这种方式恢复它。

  1. 转到Inspections (右下角)-> Configure InspectionsFile -> Settings -> Editor -> 检查

enter image description here

  1. 您可以通过从左上角的下拉菜单中选择所需的配置文件来更改检测配置文件

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

创建您自己的检查员资料。

enter image description here

关于android - 局部变量或实例字段名称与正则表达式不匹配 '[a-z]+',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38951610/

相关文章:

android - 远程aar在Android Studio中是如何工作的

python - 使用正则表达式从字符串中提取数字

Python正则表达式多次匹配

android - 无法为 flutter 医生找到 android SDK

android - 改变 ViewPager 和 setCurrentItem 的过渡速度

android - 点赞回调

android - 在推送上运行一次性 GCM 网络管理器任务

android - MPAndroid 烛台结合成交量条形图高度问题

Java : replace regexp with processed match

android-studio - 如何将桌面平台模块添加到 Android Studio 中现有的 libGDX 项目?