title: Android Studio: activity_main.xml and content_main.xml not showing design preview && ClassNotFoundException
body: <p>I want to use CircularLayout in my android app and I'm following this <a href="https://stackoverflow.com/questions/19116498/circular-layout">Circular Layout</a> . </p>
  
  <p>Errors:</p>
  
  <p>1)<strong><em>activity_main.xml and content_main.xml are not showing any design preview.</em></strong></p>
  
  <p>2)On running app, it shows <strong><em>Unfortunately, app has stopped.</em></strong></p>
  
  <p>3)The logcat shows <strong><em>ClassNotFoundException.</em></strong></p>
  
  <p>There is <strong>no compilation error or warning</strong>. </p>
  
  <p>Following is my logcat:</p>
  
  <pre><code>10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: FATAL EXCEPTION: main
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: Process: com.example.shalini.circlelayout, PID: 15699
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.shalini.circlelayout/com.example.shalini.circlelayout.MainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.shalini.circlelayout.MainActivity.Activity
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:110)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:193)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5292)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.example.shalini.circlelayout.MainActivity.Activity
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at com.example.shalini.circlelayout.MainActivity.onCreate(MainActivity.java:103)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5264)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:110) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:193) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5292) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.shalini.circlelayout.MainActivity.Activity" on path: DexPathList[[zip file "/data/app/com.example.shalini.circlelayout-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.shalini.circlelayout-2, /vendor/lib, /system/lib]]
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:559)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at com.example.shalini.circlelayout.MainActivity.onCreate(MainActivity.java:103) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.Activity.performCreate(Activity.java:5264) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:110) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:193) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5292) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
  10-03 00:27:29.609 15699-15699/com.example.shalini.circlelayout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
  </code></pre>
  
  <p>Well I inferred from it that it's not able to locate the class <strong>com.example.shalini.circlelayout.MainActivity.Activity</strong>.</p>
  
  <p>Question:</p>
  
  <p><strong><em>How do we deal with ClassNotFoundException</em></strong> in this case?</p>
  
  <p>This is how my MainActivity.java looks like:</p>
  
  <pre><code>package com.example.shalini.circlelayout;
  
  import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.RectF;
  
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.util.AttributeSet;
  import android.view.View;
  import android.view.Menu;
  import android.view.MenuItem;
  
  public class MainActivity extends AppCompatActivity {
  public class Activity extends View {
  private final static int TOTAL_DEGREE = 360;
  private final static int START_DEGREE = -90;
  
  private Paint mPaint;
  private RectF mOvalRect = null;
  
  private int mItemCount = 5;
  private int mSweepAngle;
  
  private int mInnerRadius;
  private int mOuterRadius;
  private Bitmap mCenterIcon;
  private int[] mColors = {Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.CYAN};
  private String[] mTitles = {"APPT CENTER", "MEDS CABINET", "CHECK-IN", "MY TRACKERS", "MY ACCOUNTS"};
  
  
  public Activity(Context context) {
      this(context, null);
  }
  
  public Activity(Context context, AttributeSet attrs) {
      this(context, attrs, 0);
  }
  
  public Activity(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
  
      mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mPaint.setStrokeWidth(2);
  
      mSweepAngle = TOTAL_DEGREE / mItemCount;
  
      mInnerRadius = 125;
      mOuterRadius = 400;
  
      mCenterIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
  
      int width = getWidth();
      int height = getHeight();
  
      if (mOvalRect == null) {
          mOvalRect = new RectF(width / 2 - mOuterRadius, height / 2 - mOuterRadius, width / 2 + mOuterRadius, height / 2 + mOuterRadius);
      }
  
      for (int i = 0; i &lt; mItemCount; i++) {
          int startAngle = START_DEGREE + i * mSweepAngle;
          mPaint.setColor(mColors[i]);
          mPaint.setStyle(Paint.Style.FILL);
          canvas.drawArc(mOvalRect, startAngle, mSweepAngle, true, mPaint);
  
          mPaint.setColor(Color.BLACK);
          mPaint.setStyle(Paint.Style.STROKE);
          canvas.drawArc(mOvalRect, startAngle, mSweepAngle, true, mPaint);
  
          int centerX = (int) ((mOuterRadius + mInnerRadius) / 2 * Math.cos(Math.toRadians(startAngle + mSweepAngle / 2)));
          int centerY = (int) ((mOuterRadius + mInnerRadius) / 2 * Math.sin(Math.toRadians(startAngle + mSweepAngle / 2)));
          canvas.drawBitmap(mCenterIcon, width / 2 + centerX - mCenterIcon.getWidth() / 2, height / 2 + centerY - mCenterIcon.getHeight() / 2, null);
  
          mPaint.setColor(Color.BLACK);
          mPaint.setStyle(Paint.Style.FILL);
          canvas.drawText(mTitles[i], width / 2 + centerX - mCenterIcon.getWidth() / 2, height / 2 + centerY + mCenterIcon.getHeight(), mPaint);
      }
  
      mPaint.setColor(Color.WHITE);
      mPaint.setStyle(Paint.Style.FILL);
      canvas.drawCircle(width / 2, height / 2, mInnerRadius, mPaint);
      canvas.drawBitmap(mCenterIcon, width / 2 - mCenterIcon.getWidth() / 2, height / 2 - mCenterIcon.getHeight() / 2, null);
  
      super.onDraw(canvas);
  }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                      .setAction("Action", null).show();
          }
      });
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.menu_main, menu);
  return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  // Handle action bar item clicks here. The action bar will
  // automatically handle clicks on the Home/Up button, so long
  // as you specify a parent activity in AndroidManifest.xml.
  int id = item.getItemId();
  
  //noinspection SimplifiableIfStatement
  if (id == R.id.action_settings) {
      return true;
  }
  
  return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p>This is my content_main.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:custom="http://schemas.android.com/apk/lib/com.google.custom"
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
  android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin"
  app:layout_behavior="@string/appbar_scrolling_view_behavior"
  tools:showIn="@layout/activity_main" tools:context=".MainActivity"&gt;
  &lt;com.example.shalini.circlelayout.MainActivity.Activity
  android:id="@+id/pie"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@android:color/white"
  custom:dividerWidth="5dp"
  custom:innerCircle="@drawable/profile_pic_icon"
  custom:innerRadius="50dp"
  custom:layoutMode="pie"
  custom:sliceDivider="@android:color/transparent" &gt;
  
  &lt;RelativeLayout
      android:id="@+id/appt_center_container"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/ic_launcher1" &gt;
  
      &lt;TextView
          android:id="@+id/one"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="center"
  
          android:text="@string/appcenter"
          android:textStyle="bold" /&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/ic_launcher2" &gt;
  
      &lt;TextView
          android:id="@+id/two"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
  
          android:text="@string/medscabinet"
          android:textStyle="bold" /&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/ic_launcher3" &gt;
  
      &lt;TextView
          android:id="@+id/three"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
  
          android:text="@string/cjeckin"
          android:textStyle="bold" /&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/ic_launcher4" &gt;
  
      &lt;TextView
          android:id="@+id/four"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
  
          android:text="@string/mytrackers"
          android:textStyle="bold" /&gt;
  &lt;/RelativeLayout&gt;
  
  &lt;RelativeLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/ic_launcher5" &gt;
  
      &lt;TextView
          android:id="@+id/five"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:gravity="center"
  
          android:text="@string/myaccounts"
          android:textStyle="bold" /&gt;
  &lt;/RelativeLayout&gt;
  &lt;/com.example.shalini.circlelayout.MainActivity.Activity&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And here is the activity_main.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
  android:layout_height="match_parent" android:fitsSystemWindows="true"
  tools:context=".MainActivity"&gt;
  
  &lt;android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
      android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
      &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar"
          android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;include layout="@layout/content_main" /&gt;
  
  &lt;android.support.design.widget.FloatingActionButton android:id="@+id/fab"
      android:layout_width="wrap_content" android:layout_height="wrap_content"
      android:layout_gravity="bottom|end"   android:layout_margin="@dimen/fab_margin"
      android:src="@android:drawable/ic_dialog_email" /&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>