Search code examples
androidxmlandroid-studiogradlepreview

Android XML Preview - "The following classes could not be found"


Im trying to use Material library: Material; but when i add a Button (from library) the Xml preview from Android Studio (1.2.1.1) keeps returning me the error:

The following classes could not be found: - com.gc.materialdesign.views.Button (Fix Build Path, Create Class) Tip: Try to build the project.

I already did Build, Clean, Restart Android Studio, change preview API on XML editor, and nothing seems to work.

On build.grade i modified this in order to add the library:

repositories {
    jcenter()
}

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:22.0.0'
  compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
}

Other info:

minSDK = 16
targetSDK=21
compileSDK=21
gradle Version = 1.2.3

test_layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0f">

<com.gc.materialdesign.views.Button
    android:id="@+id/login_btn_login"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button text"/>
</RelativeLayout>

What else can i do for this error from XML preview go away? The application runs without any error but i can't preview the button on XML preview window.

Thanks guys!


Solution

  • If someone is facing the same problem this is the way i managed to solve the problem:

    downgrade Android Studio 1.2.1.1 to 1.1.0.