我对Android开发还比较新,正在尝试使用Android Design Support Library和这篇指南在Android Studio中设置一个浮动操作按钮。
我的项目:注意到的build.gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
我的模块:app build.gradle 文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.noted"
minSdkVersion 21
targetSdkVersion 22
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:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:design:22.2.0'
}
在我的activity_main.xml
中,我尝试实现
<android.support.design.widget.FloatingActionButton
... />
但是在构建后,我遇到了一个渲染问题弹窗,上面写着:
找不到以下类: - android.support.design.widget.FloatingActionButton
我的猜测是我在依赖方面做错了什么,但我真的不知道。我已经尝试了几个小时来解决这个问题,但没有成功,我真的很感激任何帮助。
谢谢!