错误:包 android.support.design.widget 不存在 [英] error: package android.support.design.widget does not exist
问题描述
我是安卓新手.当我想将一个项目导入我的 android studio 时,它会抱怨这个错误:错误包 android.support.design.widget 不存在
i'm new to android. when i want to import a project into my android studio it complain about this error that : error package android.support.design.widget does not exist
这是我的代码:
public class CatalogActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_catalog);
// Setup FAB to open EditorActivity
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(CatalogActivity.this, EditorActivity.class);
startActivity(intent);
}
});
}
}
这是我的 build.gradle:
and this is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.pets"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.getbase:floatingactionbutton:1.9.1'
}
我该如何解决这个问题以及另一件事,每次我想将另一个其他项目导入我的 android studio 时,都会出现一堆错误,需要更改 build.gradle 和 build.gradle.properties 并且每次我有这样的问题.谁能给我一个关于这个 build.gradle 的参考资料,以了解它应该如何?
how can i solve this problem and one another thing that every time that i want to import another else project into my android studio there is bunch of error and need to change build.gradle and build.gradle.properties and every time i have some problem like this . can anyone give me a reference about this build.gradle to learn how it should be ?
推荐答案
浮动操作 按钮用于特殊类型的升级操作.所以你需要添加com.android.support:design library
在你的 build.gradle 中也包括这一行:
Floating action buttons are used for a special type of promoted action. so you need to add com.android.support:design library
Include this line also in your build.gradle:
在你的build.gradle
中编译这个dependencies
:
compile 'com.android.support:design:25.3.1'
这篇关于错误:包 android.support.design.widget 不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!