将 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'
这是屏幕截图。
如果我将同一个类文件复制到另一个新项目,则不会出现警告。只有旧项目显示这些警告。 这是我的 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'
}
我试过 文件菜单 -> 使缓存无效/重新启动
,但没有帮助。
我想解决问题而不是忽略警告。
任何帮助深表感谢。谢谢。
最佳答案
您的检查资料已更改。您可以通过这种方式恢复它。
- 转到Inspections (右下角)-> Configure Inspections 或File -> Settings -> Editor -> 检查
- 您可以通过从左上角的下拉菜单中选择所需的配置文件来更改检测配置文件
或
从列表中禁用任何不需要的检查。
或
创建您自己的检查员资料。
关于android - 局部变量或实例字段名称与正则表达式不匹配 '[a-z]+',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38951610/