I am a beginner to Android Programming. I am trying to create a basic Hello World App using Android Studio. I am getting following errors in Java File immediately after following the initial steps to create the Hello World Program.
"Cannot resolve Symbol FloatingActionButton"
"Cannot resolve Symbol Snackbar"
"Cannot resolve Symbol AppCompatActivity"
"Cannot resolve Symbol Toolbar"
As you can see in the attached Image the errors are in red. Please help me out here.
My build file content:
defaultConfig {
applicationId "com.example.helloworld.helloworld"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
Seems like I have added all the relevant dependencies.
I had the same issue after inserting a new module with a blank activity into an existing project.
My module's build.gradle
file looked like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.networkingtest"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
}
To resolve the issue I changed the versions of the appcompat and design dependencies from 23.1.0 to 23.0.1 (Note: this is the same version as in buildToolsVersion
). Next I hit "Sync project with gradle files" followed by Build > Clean Project. After completion the project would run, but I changed the dependency versions back to 23.1.0, hit "Sync project with gradle files" followed by Build > Clean Project again. Now everything works.
Include compile 'com.android.support:design:25.3.1'
in build.gradle(Module:app)
Change the version 25.3.1
to match your compile 'com.android.support:appcompat-v7:25.3.1'
dependency
Import import android.support.design.widget.FloatingActionButton;
in activity
Did you sync your project?
Also try deleting all "red" imports and re-import this classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With