title: Android Studio: ClassNotFoundException
body: <p>i was busy with my app for over a week, when suddenly:</p>
  
  <pre><code>11-12 07:59:17.860    1653-1653/nl.test.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{nl.test.MyApp/nl.test.MyApp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "nl.test.myapp.MainActivity" on path: DexPathList[[zip file "/data/app/nl.test.myapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/nl.test.myapp-2, /system/lib]]
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
          at android.app.ActivityThread.access$600(ActivityThread.java:141)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:137)
          at android.app.ActivityThread.main(ActivityThread.java:5103)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:525)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
          at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.ClassNotFoundException: Didn't find class "nl.test.myapp.MainActivity" on path: DexPathList[[zip file "/data/app/nl.test.MyApp-2.apk"],nativeLibraryDirectories=[/data/app-lib/nl.test.MyApp-2, /system/lib]]
          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
          at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
          at android.app.ActivityThread.access$600(ActivityThread.java:141)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:137)
          at android.app.ActivityThread.main(ActivityThread.java:5103)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:525)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>here is my AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="nl.test.myapp"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="7"
          android:targetSdkVersion="19" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="nl.test.myapp.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity android:name=".welcomewizard.WelcomeWizardIntroPage"
              android:label="@string/app_name" /&gt;
  
          &lt;activity android:name=".welcomewizard.WelcomeWizardPage1"
              android:label="@string/app_name" /&gt;
  
          &lt;activity android:name=".welcomewizard.WelcomeWizardPage2"
              android:label="@string/app_name" /&gt;
  
          &lt;activity android:name=".welcomewizard.WelcomeWizardPage3"
              android:label="@string/app_name" /&gt;
  
          &lt;activity android:name=".welcomewizard.WelcomeWizardPage4"
              android:label="@string/app_name" /&gt;
  
          &lt;activity android:name=".welcomewizard.WelcomeWizardFinishPage"
              android:label="@string/app_name" /&gt;
  
          &lt;activity android:name=".CompanySelectorActivity"
              android:label="@string/compsel_actionbarlabel" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>this was happening after some problems with my R.java (the id's for the views where incorrect), after rebuilding the project this problem happend</p>
  
  <p>i've already tried the Invalidate Cashes/restart in the IDE File-menu</p>
  
  <p><strong>Update 14:51</strong>:
  this is my compiler.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project version="4"&gt;
    &lt;component name="CompilerConfiguration"&gt;
      &lt;option name="DEFAULT_COMPILER" value="Javac" /&gt;
      &lt;resourceExtensions /&gt;
      &lt;wildcardResourcePatterns&gt;
        &lt;entry name="!?*.java" /&gt;
        &lt;entry name="!?*.form" /&gt;
        &lt;entry name="!?*.class" /&gt;
        &lt;entry name="!?*.groovy" /&gt;
        &lt;entry name="!?*.scala" /&gt;
        &lt;entry name="!?*.flex" /&gt;
        &lt;entry name="!?*.kt" /&gt;
        &lt;entry name="!?*.clj" /&gt;
      &lt;/wildcardResourcePatterns&gt;
      &lt;annotationProcessing&gt;
        &lt;profile default="true" name="Default" enabled="false"&gt;
          &lt;processorPath useClasspath="true" /&gt;
        &lt;/profile&gt;
      &lt;/annotationProcessing&gt;
    &lt;/component&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>My MainActivity.java file (\src\main\java\nl\test\myapp\MainActivity.java) :</p>
  
  <pre><code>package nl.test.myapp;
  
  import android.annotation.TargetApi;
  import android.content.Intent;
  import android.os.Build;
  import android.os.Bundle;
  import android.support.v7.app.ActionBarActivity;
  import android.view.Menu;
  import android.widget.RelativeLayout;
  
  import nl.test.myapp.welcomewizard.WelcomeWizardIntroPage;
  
  public class MainActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          setBackground(R.drawable.background_grey);
  
          Intent intent = new Intent(this, WelcomeWizardIntroPage.class);
          startActivity(intent);
          finish();
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
  
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
      private void setBackground(int drawable){
          int currentApiVersion = android.os.Build.VERSION.SDK_INT;
          if(currentApiVersion &gt;= android.os.Build.VERSION_CODES.JELLY_BEAN){
              RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_main);
              layout.setBackground(getResources().getDrawable(drawable));
          }
      }
  }
  </code></pre>