java.lang.RuntimeException: Unable to start activity ComponentInfo
<p>i know this error appeared on forum milion of times, but please help me find what i missed
i'm trying to do simple tab orientated application i don't have much (except errors)</p>

<p>1) my main activity is based on tablayout tutorial what i found</p>

<pre><code>public class MainTabPanel extends TabActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainlayout);
        Resources res = getResources();
        TabHost tabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;
        intent = new Intent().setClass(this, MyBookActivity.class);
        spec = tabHost.newTabSpec("main")
                .setIndicator("Main", res.getDrawable(R.drawable.ic_mybook))
                .setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);
    }

}
</code></pre>

<p>2) mainlayout.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@android:id/tabhost"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"&gt;
 &lt;LinearLayout  
   android:orientation="vertical"  
   android:layout_width="fill_parent"     
   android:layout_height="fill_parent"        
   android:padding="5dp"&gt;
 &lt;TabWidget 
  android:id="@android:id/tabs" 
  android:layout_width="fill_parent"
  android:layout_height="wrap_content" /&gt;        

  &lt;FrameLayout      
  android:id="@android:id/tabcontent" 
  android:layout_width="fill_parent"   
  android:layout_height="fill_parent"
  android:padding="5dp" /&gt;   
 &lt;/LinearLayout&gt;&lt;/TabHost&gt;
</code></pre>

<p>3) my second activity is basically almost empty, it;s just display current date and time, worked before i tried to add tab panel</p>

<p>4) my manifest file</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.th.mybook"
    android:versionCode="1"
    android:versionName="1.0" &gt;
    &lt;uses-sdk android:minSdkVersion="8" /&gt;
    &lt;application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" &gt;
        &lt;activity
            android:name=".MainTabPanel"
            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="MyBookActivity"
            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.ALTERNATIVE" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;
&lt;/manifest&gt;
</code></pre>

<p>5 log cat error</p>

<pre><code>02-10 21:04:45.203: E/AndroidRuntime(1107): FATAL EXCEPTION: main
02-10 21:04:45.203: E/AndroidRuntime(1107): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.th.mybook/org.th.mybook.MainTabPanel}: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.th.mybook/org.th.mybook.MyBookActivity}: java.lang.NullPointerException
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.os.Looper.loop(Looper.java:123)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.main(ActivityThread.java:4627)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at java.lang.reflect.Method.invokeNative(Native Method)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at java.lang.reflect.Method.invoke(Method.java:521)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at dalvik.system.NativeStart.main(Native Method)
02-10 21:04:45.203: E/AndroidRuntime(1107): Caused by: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.th.mybook/org.th.mybook.MyBookActivity}: java.lang.NullPointerException
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.widget.TabHost.setCurrentTab(TabHost.java:323)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.widget.TabHost.addTab(TabHost.java:213)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at org.th.mybook.MainTabPanel.onCreate(MainTabPanel.java:30)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
02-10 21:04:45.203: E/AndroidRuntime(1107):     ... 11 more
02-10 21:04:45.203: E/AndroidRuntime(1107): Caused by: java.lang.NullPointerException
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:100)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at org.th.mybook.MyBookActivity.&lt;init&gt;(MyBookActivity.java:16)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at java.lang.Class.newInstanceImpl(Native Method)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at java.lang.Class.newInstance(Class.java:1429)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
02-10 21:04:45.203: E/AndroidRuntime(1107):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
02-10 21:04:45.203: E/AndroidRuntime(1107):     ... 20 more
</code></pre>

<p>please help me, and tell me what i missed, im comparing this code with my old one and i can't find anything
regards</p>

<p>6) my book activity</p>

<pre><code>public class MyBookActivity extends Activity {
    java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext()); 

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        DigitalClock clock = (DigitalClock) findViewById(R.id.digitalClock1);
        final TextView date = (TextView) findViewById(R.id.textView1);
        date.setText(dateFormat.format(new Date()));
        TextWatcher watcher = new TextWatcher() {

            @Override
            public void afterTextChanged(Editable s) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before,
                    int count) {

                if (s.toString().startsWith("00:00:00")
                        || s.toString().startsWith("12:00:00")) {
                    date.setText(dateFormat.format(new Date()));
                }
            }
        };
        clock.addTextChangedListener(watcher);

    }
}
</code></pre>

<p>7) main.xml layout -> for my book activity</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="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="right"
    android:orientation="horizontal" &gt;


    &lt;LinearLayout
        android:id="@+id/DatePanel1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" &gt;


        &lt;TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/space"
            android:layout_weight="1"
            android:text="TextView" /&gt;

        &lt;DigitalClock
            android:id="@+id/digitalClock1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="DigitalClock" /&gt;
    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>
