title: Android - java.lang.SecurityException: Permission Denial: starting Intent
body: <p>I have a library (jar) on build path of my project. The project accesses the MainActivity in the jar, using the following intent:</p>
  
  <pre><code>final Intent it = new Intent();
  it.setClassName("com.example.lib", "com.example.lib.MainActivity");
  startActivity(it);
  </code></pre>
  
  <p>It used to work for sometime, but suddenly started getting 'ActivityNotFoundException: No Activity found to handle Intent' which I was able to resolve. But now I am stuck with a 'java.lang.SecurityException: Permission Denial: starting Intent'.</p>
  
  <p>I have tried all suggestions made on stackoverflow (check for duplicates in manifest file; add android:exported="true" to lib manifest; Eclipse> Project> Clean; adding/ modifying 'intent-filter' tags; etc.). I even tried re-writing the manifest of the project but not going anywhere with it.</p>
  
  <p>Here's the logcat output:</p>
  
  <pre><code>11-07 06:20:52.176: E/AndroidRuntime(4626): FATAL EXCEPTION: main
  11-07 06:20:52.176: E/AndroidRuntime(4626): java.lang.SecurityException: Permission     Denial: starting Intent { cmp=com.example.lib/.MainActivity } from ProcessRecord{40dd3778     4626:com.example.project/u0a10046} (pid=4626, uid=10046) not exported from uid 10047
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.os.Parcel.readException(Parcel.java:1425)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.os.Parcel.readException(Parcel.java:1379)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1885)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1412)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.Activity.startActivityForResult(Activity.java:3370)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.Activity.startActivityForResult(Activity.java:3331)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:824)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.Activity.startActivity(Activity.java:3566)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.Activity.startActivity(Activity.java:3534)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.example.project.MainActivity.onOptionsItemSelected(MainActivity.java:93)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.Activity.onMenuItemSelected(Activity.java:2548)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:366)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:980)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:149)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:547)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:115)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.view.View.performClick(View.java:4204)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.view.View$PerformClick.run(View.java:17355)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.os.Handler.handleCallback(Handler.java:725)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.os.Handler.dispatchMessage(Handler.java:92)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.os.Looper.loop(Looper.java:137)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at android.app.ActivityThread.main(ActivityThread.java:5041)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at java.lang.reflect.Method.invoke(Method.java:511)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  11-07 06:20:52.176: E/AndroidRuntime(4626):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Manifest XML of Project:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.project"
  android:versionCode="4"
  android:versionName="4.0" &gt;
  
  &lt;!-- Permissions --&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;supports-screens android:anyDensity="true" /&gt;
  
  &lt;!-- SDK Settings --&gt;
  &lt;uses-sdk
      android:minSdkVersion="11"
      android:targetSdkVersion="18" /&gt;
  
  &lt;!-- APP Start --&gt;
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
  
  &lt;!-- App Activity --&gt;
      &lt;activity
          android:name="com.example.project.MainActivity"
          android:label="@string/app_name"
          android:screenOrientation="portrait" &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;!-- Library Activity --&gt;
      &lt;activity android:name="com.example.lib.MainActivity" android:label="LibMain"&gt;
           &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN"&gt;&lt;/action&gt;
       &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
  &lt;/application&gt;
  &lt;!-- END - APP --&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>What am I overlooking? Any suggestions?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I updated the manifest.xml with all other activities &amp; somehow, that resolved the problem. The intent activity starts up without any errors. <em>BUT</em>, this is only on AVD. On actual device, it is still throwing same error. I have uninstalled the app from device completely and reinstalled, yet the same error.</p>