title: java.lang.RuntimeException: Unable to Instantiate activity ComponentInfo
body: <p>I am creating a widget but when I run it I get this error in the console:</p>
  
  <pre><code>[2013-10-05 22:02:56 - AwesomeFileBuilderWidget] ------------------------------
  [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] Android Launch!
  [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] adb is running normally.
  [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] No Launcher activity found!
  [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] The launch will only sync the application package on the device!
  [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] Performing sync
  [2013-10-05 22:02:56 - AwesomeFileBuilderWidget] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
  [2013-10-05 22:03:00 - AwesomeFileBuilderWidget] Uploading AwesomeFileBuilderWidget.apk onto device 'HT18YMA05067'
  [2013-10-05 22:03:00 - AwesomeFileBuilderWidget] Installing AwesomeFileBuilderWidget.apk...
  [2013-10-05 22:03:04 - AwesomeFileBuilderWidget] Success!
  [2013-10-05 22:03:04 - AwesomeFileBuilderWidget] \AwesomeFileBuilderWidget\bin\AwesomeFileBuilderWidget.apk installed on device
  [2013-10-05 22:03:04 - AwesomeFileBuilderWidget] Done!
  </code></pre>
  
  <p>But the widget installs fine on my device and shows up in the Widget selection screen. </p>
  
  <p>The second error occurs when I try to put my widget on the homescreen. I get this error in LogCat:</p>
  
  <pre><code>10-05 21:51:45.485: D/AndroidRuntime(3557): Shutting down VM
  10-05 21:51:45.485: W/dalvikvm(3557): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
  10-05 21:51:45.505: E/AndroidRuntime(3557): FATAL EXCEPTION: main
  10-05 21:51:45.505: E/AndroidRuntime(3557): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.awesomefilebuilderwidget/com.example.awesomefilebuilderwidget.WidgetConfig}: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk]
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1746)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:1854)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.os.Handler.dispatchMessage(Handler.java:99)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.os.Looper.loop(Looper.java:150)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.ActivityThread.main(ActivityThread.java:4333)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at java.lang.reflect.Method.invoke(Method.java:507)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at dalvik.system.NativeStart.main(Native Method)
  10-05 21:51:45.505: E/AndroidRuntime(3557): Caused by: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk]
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1738)
  10-05 21:51:45.505: E/AndroidRuntime(3557):     ... 11 more
  </code></pre>
  
  <p>Here is my Manifest:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.awesomefilebuilderwidget"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
  android:minSdkVersion="8"
  android:targetSdkVersion="18" /&gt;
  
  &lt;application
  android:allowBackup="true"
  android:icon="@drawable/ic_launcher"
  android:label="@string/app_name"
  android:theme="@style/AppTheme" &gt;
  
  &lt;receiver android:name=".AFBWidget" android:label="@string/app_name"&gt;
  &lt;intent-filter&gt;
  &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE"/&gt;
  &lt;/intent-filter&gt;
  
  &lt;meta-data android:name="android.appwidget.provider"
  android:resource="@xml/widget_stuff"/&gt;
  
  &lt;/receiver&gt;
  
  &lt;activity android:name=".WidgetConfig" android:label="@string/app_name"&gt;
  &lt;intent-filter&gt;
  &lt;action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/&gt;
  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;     
  &lt;/intent-filter&gt; 
  
  &lt;/activity&gt;   
  
  &lt;activity android:name=".AFBWidget" android:label="@string/app_name"/&gt;
  
  
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>I have made sure I have checked all the boxes in the Order and Export section. I have also made sure that my AFBWidget and WidgetConfig classes are in src. (Please note that the actual widget configuration is in the correct xml location, the WidgetConfig.java is something else)</p>
  
  <p>What is the issue?</p>
  
  <p>Updated LogCat:</p>
  
  <pre><code>10-05 22:47:40.628: D/AndroidRuntime(4113): Shutting down VM
  10-05 22:47:40.628: W/dalvikvm(4113): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
  10-05 22:47:40.638: E/AndroidRuntime(4113): FATAL EXCEPTION: main
  10-05 22:47:40.638: E/AndroidRuntime(4113): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.awesomefilebuilderwidget/com.example.awesomefilebuilderwidget.WidgetConfig}: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk]
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1746)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1854)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.os.Handler.dispatchMessage(Handler.java:99)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.os.Looper.loop(Looper.java:150)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.ActivityThread.main(ActivityThread.java:4333)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at java.lang.reflect.Method.invoke(Method.java:507)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at dalvik.system.NativeStart.main(Native Method)
  10-05 22:47:40.638: E/AndroidRuntime(4113): Caused by: java.lang.ClassNotFoundException: com.example.awesomefilebuilderwidget.WidgetConfig in loader dalvik.system.PathClassLoader[/data/app/com.example.awesomefilebuilderwidget-1.apk]
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1738)
  10-05 22:47:40.638: E/AndroidRuntime(4113):     ... 11 more
  </code></pre>
  
  <p>ADDED CLASSES AND XML FILES:
  AFBWidget.java:</p>
  
  <pre><code>import java.util.Random;
  
  import com.example.awesomefilebuilderwidget.R;
  import android.appwidget.AppWidgetManager;
  import android.appwidget.AppWidgetProvider;
  import android.content.Context;
  import android.widget.RemoteViews;
  import android.widget.Toast;
  
  
  public class AFBWidget extends AppWidgetProvider{
  
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager,
          int[] appWidgetIds) {
      // TODO Auto-generated method stub
      super.onUpdate(context, appWidgetManager, appWidgetIds);
      Random r = new Random();
      int randomInt = r.nextInt(1000000000);
      String rand = String.valueOf(randomInt);
  
      final int N = appWidgetIds.length;
  
      for (int i = 0; i &lt; N; i++){
          int awID = appWidgetIds[i];
          RemoteViews v = new RemoteViews(context.getPackageName(), R.layout.widget);
          v.setTextViewText(R.id.tvwidgetUpdate, rand);
          appWidgetManager.updateAppWidget(awID, v);
      }
  
  }
  </code></pre>
  
  <p>WidgetConfig.java:</p>
  
  <pre><code>import android.app.Activity;
  import android.app.PendingIntent;
  import android.appwidget.AppWidgetManager;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.RemoteViews;
  
  import com.example.awesomefilebuilderwidget.R;
  
  
  public class WidgetConfig extends Activity implements OnClickListener{
  
  EditText info;
  AppWidgetManager awm;
  Context c;
  int awID;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.widgetconfig);
      Button b = (Button)findViewById(R.id.bwidgetconfig);
      b.setOnClickListener(this);
      c = WidgetConfig.this;
      info = (EditText)findViewById(R.id.etwidgetconfig);
      //Getting info about the widget that launched this Activity
      Intent i = getIntent();
      Bundle extras = i.getExtras();
      if (extras != null){
          awID = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
                  AppWidgetManager.INVALID_APPWIDGET_ID
                  );
      }else{
          finish();
      }
      awm = AppWidgetManager.getInstance(c);
  }
  
  @Override
  public void onClick(View v) {
      // TODO Auto-generated method stub
      String e = info.getText().toString();
  
      RemoteViews views = new RemoteViews(c.getPackageName(), R.layout.widget);
      views.setTextViewText(R.id.tvConfigInput, e);
  
      Intent in = new Intent(c, WidgetConfig.class);
      PendingIntent pi = PendingIntent.getActivity(c, 0, in, 0);
      views.setOnClickPendingIntent(R.id.bwidgetOpen, pi);
  
      awm.updateAppWidget(awID, views);
  
      Intent result = new Intent();
      result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, awID);
      setResult(RESULT_OK, result);
  
      finish();
  }
  
  
  }
  </code></pre>
  
  <p>Widget.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;TextView
      android:id="@+id/tvConfigInput"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="TextView" /&gt;
  
  &lt;Button
      android:id="@+id/bwidgetOpen"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Button" /&gt;
  
  &lt;TextView
      android:id="@+id/tvwidgetUpdate"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="TextView" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>WidgetConfig.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;EditText
      android:id="@+id/etwidgetconfig"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:ems="10" 
      android:hint="@string/user_input_application_name"&gt;
  
      &lt;requestFocus /&gt;
  &lt;/EditText&gt;
  
  &lt;Button
      android:id="@+id/bwidgetconfig"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="@string/ok" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>App Widget Provider (app_stuff.xml):
  <img src="https://i.stack.imgur.com/Ob6Xs.png" alt="enter image description here"></p>