错误:找不到符号变量LOLLIPOP [英] Error: cannot find symbol variable LOLLIPOP
问题描述
我在不同的android库中看到了许多有关检测设备是否受LOLLIPOP支持的示例。但是当我在应用程序中使用它时,它抛出以下错误:
I have seen many examples in different android libraries about detecting if device is LOLLIPOP supported or not. But when I use it in my app, it is throwing the following error:
错误:(20,60)错误:找不到符号变量LOLLIPOP
Error:(20, 60) error: cannot find symbol variable LOLLIPOP
例如,我的源代码是:
static boolean isLollipop() {
return Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1;
}
我正在使用最新版本的Android Studio,并且已更新并安装了所有软件包。
I am using the latest version of Android Studio with all packages updated and installed.
该语句出现错误:
Build.VERSION_CODES.LOLLIPOP
另外,当我检查 VERSION_CODES
选项时, LOLLIPOP
在该列表中不存在。
Also when I check options of VERSION_CODES
, LOLLIPOP
does not exist in that list.
推荐答案
您正在使用旧的构建工具,或者缺少某些库。
it seems to that you're using old build tools or you're missing some libraries.
我将代码粘贴到Android Studio中,并且可以正常工作。
I pasted your code into my Android Studio and it works.
请与您的 build.gradle
进行比较:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23 //THIS GUY
buildToolsVersion "23.0.2" //THIS GUY
defaultConfig {
applicationId "com.example.piotr.myapplication"
minSdkVersion 15
targetSdkVersion 23 //THIS GUY
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1' //THIS GUY
compile 'com.android.support:design:23.1.1'
}
I已经匹配了可能对您的代码很重要的部分。
I've already matched parts which might be important to your code.
希望对您有所帮助
这篇关于错误:找不到符号变量LOLLIPOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!