1

I know this is common question, but I have tried

  • Cleaning and Rebuilding Project
  • Invalidating and restarting
  • Setting build version to other that 22
  • Changing version of Gradle
  • adding Base. in styles.xml and none of this doesn't fix the issue.

It's seems that this time the problem is somewhere else, because all elements are up-to-date.

I am getting following error at the preview screen in Android Studio :

The following classes could not be found:
- android.support.v7.widget.Toolbar

Gradle version is 1.2.3. I have just installed Android Studio + SDK.

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

and

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 21
        buildToolsVersion '22.0.1'

        defaultConfig {
            applicationId "com.sth.sth"
            minSdkVersion 15
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:cardview-v7:21.0.3'
    ...
}
filipp.kowalski
  • 5,495
  • 7
  • 27
  • 45

1 Answers1

0

You're using the toolbar from the support library, but it seems that you aren't including it as a dependency. You should add something like this in your build.gradle file:

dependencies {
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
}
Alex Florescu
  • 5,096
  • 1
  • 28
  • 49