【发布时间】:2014-11-16 18:45:02
【问题描述】:
当我在即将试用 Android 5.0 Lollipop 时尝试在测试项目中使用 RecyclerView 时,我在 Google 网站上看到以下内容:
-
让我感到困惑的是,他们使用了支持的东西,而不是 API 21 中提供的“真实”的东西。我希望不使用支持包,因为我在设备上运行 5.0,下载了 SDK 21 并安装。为什么我不能直接使用RecyclerView,不使用支持...?
-
找不到类。在 Android Studio 中,我收到此错误:
“此处不允许使用元素 RecyclerView”,没有更多信息。另外,如果我使用上面发布的示例,我会得到同样的错误:
如果我点击“修复构建路径”,我会看到:
我在使用 Java 和 Android 时总是遇到这些问题,但错误消息不清楚。 sdk 的路径正确(在 SDK Location 下)。
这是我的毕业典礼:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "se.snapcode.lollipoptest"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.snapcode.lollipoptest" >
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
【问题讨论】:
标签: android sdk android-studio android-5.0-lollipop