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 ?
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: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.
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 yourbuild.gradle
:Add following in gradle file :