title: Android application activity unable to start componentinfo
body: <p>much of the code comes from <a href="https://stackoverflow.com/questions/15051204/download-image-and-display-it">Download image and display it</a>, so I was surprised when it didn't work. I've searched all around and cannot figure it out</p>
  
  <p>here's the "mainactivity".java in this case called LleUrlEnter.java</p>
  
  <pre><code>    package lle.imagedownloader;
  
  import android.app.Activity;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import java.net.URL;
  import android.widget.ImageView;
  
  public class LleUrlEnter extends Activity {
  
      private ImgDownloadTask task;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          String imgLink = "http://imgur.com/8WzhDgI";
          task = new ImgDownloadTask();
          task.onPostExecute(task.doInBackground(imgLink));
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.lle_url_enter, 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();
          if (id == R.id.action_settings) {
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
      private class ImgDownloadTask extends AsyncTask&lt;String, Void, Bitmap&gt; {
  
  
          protected Bitmap doInBackground(String...urls) {
              String link = urls[0];
              Bitmap imgBitmap = null;
  
              try {
                  imgBitmap = BitmapFactory.decodeStream(new URL(link).openConnection().getInputStream());
                  }
  
              catch (Exception e) {
                  e.printStackTrace();
                  }
              return imgBitmap;
              }
  
  
          protected void onPostExecute(Bitmap bitmapImage) {
              ImageView bitImg = (ImageView) findViewById(R.id.imageView1);
              bitImg.setImageBitmap(bitmapImage);
          }
      }
  }
  </code></pre>
  
  <p>then the "main.xml" called activity_lle_url_enter.xml</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".LleUrlEnter" &gt;
  
  &lt;ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_centerVertical="true"
      android:layout_marginLeft="144dp" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>and then finally the android manifest</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="lle.imagedownloader"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="21" /&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=".LleUrlEnter"
              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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>and this is what LogCat shows me</p>
  
  <pre><code>07-16 16:27:29.119: E/Trace(11735): error opening trace file: No such file or directory (2)
  07-16 16:27:29.166: W/System.err(11735): android.os.NetworkOnMainThreadException
  07-16 16:27:29.166: W/System.err(11735):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1131)
  07-16 16:27:29.166: W/System.err(11735):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
  07-16 16:27:29.166: W/System.err(11735):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
  07-16 16:27:29.166: W/System.err(11735):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpConnection.&lt;init&gt;(HttpConnection.java:70)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpConnection.&lt;init&gt;(HttpConnection.java:50)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
  07-16 16:27:29.166: W/System.err(11735):    at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
  07-16 16:27:29.166: W/System.err(11735):    at lle.imagedownloader.LleUrlEnter$ImgDownloadTask.doInBackground(LleUrlEnter.java:53)
  07-16 16:27:29.166: W/System.err(11735):    at lle.imagedownloader.LleUrlEnter.onCreate(LleUrlEnter.java:23)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.Activity.performCreate(Activity.java:5058)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2174)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.ActivityThread.access$700(ActivityThread.java:141)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1267)
  07-16 16:27:29.166: W/System.err(11735):    at android.os.Handler.dispatchMessage(Handler.java:99)
  07-16 16:27:29.166: W/System.err(11735):    at android.os.Looper.loop(Looper.java:137)
  07-16 16:27:29.166: W/System.err(11735):    at android.app.ActivityThread.main(ActivityThread.java:5059)
  07-16 16:27:29.166: W/System.err(11735):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-16 16:27:29.166: W/System.err(11735):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-16 16:27:29.166: W/System.err(11735):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
  07-16 16:27:29.166: W/System.err(11735):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
  07-16 16:27:29.166: W/System.err(11735):    at dalvik.system.NativeStart.main(Native Method)
  07-16 16:27:29.197: D/AndroidRuntime(11735): Shutting down VM
  07-16 16:27:29.197: W/dalvikvm(11735): threadid=1: thread exiting with uncaught exception (group=0x40ebd2a0)
  07-16 16:27:29.197: E/AndroidRuntime(11735): FATAL EXCEPTION: main
  07-16 16:27:29.197: E/AndroidRuntime(11735): java.lang.RuntimeException: Unable to start activity ComponentInfo{lle.imagedownloader/lle.imagedownloader.LleUrlEnter}: java.lang.NullPointerException
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2136)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2174)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.ActivityThread.access$700(ActivityThread.java:141)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1267)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.os.Handler.dispatchMessage(Handler.java:99)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.os.Looper.loop(Looper.java:137)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.ActivityThread.main(ActivityThread.java:5059)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at java.lang.reflect.Method.invokeNative(Native Method)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at java.lang.reflect.Method.invoke(Method.java:511)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at dalvik.system.NativeStart.main(Native Method)
  07-16 16:27:29.197: E/AndroidRuntime(11735): Caused by: java.lang.NullPointerException
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at lle.imagedownloader.LleUrlEnter$ImgDownloadTask.onPostExecute(LleUrlEnter.java:65)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at lle.imagedownloader.LleUrlEnter.onCreate(LleUrlEnter.java:23)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.Activity.performCreate(Activity.java:5058)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
  07-16 16:27:29.197: E/AndroidRuntime(11735):    ... 11 more
  </code></pre>