NoClassDefFoundError: Failed resolution of: Landroid/support/v7/appcompat/R$styleable

You are getting that error because of the following reasons:

In your Gradle build file your app is targeting and compiling with the beta version of Android that is still in development with:

compileSdkVersion 'android-L'
buildToolsVersion '20'

as well as

minSdkVersion 20
targetSdkVersion 20

First thing to note is that this app will not run correctly (at this time) on any device without android-L flashed to it.

The real crux of your issue is in DisplayMessageActivity, it extends via inheritance [ActionBarActivity]:(https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html) this is one of the support library classes for AppCompat.

To fix this, change your min SDK to 10 (or 14 which is ice cream sandwich), your max SDK to 19 (Kit Kat) and un-comment the appcompat-v7 library in your dependencies.

As a side note, when you declare widgets in their respective activities/fragments it's usually good practice to have their scope be outside of any methods:

EditText editText;
Button sendMessageButton;

// Then in your onCreate() method
editText = (EditText) findViewById(R.id.editText);
sendMessageButton = (Button) findViewById(R.id.sendMessageButton);

This helps reduce memory re-allocation and make your code a little more readable. Sometimes you may have to bend the rules a bit but this is the common practice.


I deleted 'build' folder in "yourAppName\app" folder

and everything worked fine. If above solution didn't work, try this. build folder will be auto-generate when you build your project again.


Just
     Build -> Clean Project
and then
     Build -> Rebuild Project.
That's all.