error: package android.support.design.widget does not exist

旧时模样 提交于 2019-12-02 16:19:21

问题


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

here is my code :

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);
    }
});
}
}

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'
}

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 ?


回答1:


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:

compile this dependencies in your build.gradle:

compile 'com.android.support:design:25.3.1'



回答2:


Add following in gradle file :

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'



回答3:


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:

compile 'com.android.support:design:25.3.1'



回答4:


FloatingActionButton is available in com.android.support:design library. If you are using any class that class related libraries you need to include in build.gradle, that's why you are getting error.



来源:https://stackoverflow.com/questions/45301935/error-package-android-support-design-widget-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!