Q:

Java/Android: Unable to start activity ComponentInfo{...}: java.lang.NullPointerException

Here is one of my first apps - for now, it is supposed to act as TCP terminal with a HLK-RM04.
I know this error has been posted before, but I have not found any solution applicable to my code. Help will be appreciated. 
NOTE #1: The same error is given even if the connection is available. 
NOTE #2: If I remove lines 77-84 and 98, no error is given if connection is available (if it's not, the app just exits). 
Code that appears to be faulty:
package com.milk.milkdispenser;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.util.Log;
import android.os.Handler;

import java.util.Timer;
import java.util.TimerTask;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.io.IOException;

public class MainActivity extends Activity {

    //Debug string
    String msg= "milkMsg";

    //Variables
    String tmp;

    //Declaring buffers...
    PrintWriter outp;
    BufferedReader inp;

    //Objects
    EditText txt;
    Button send;
    Button clear;
    TextView output;

    //Handler
    final Handler MyHandler = new Handler();

    //Socket

    Socket s;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main);
        Log.d(msg, "Starting app...");

        //assigning objects

        txt = (EditText) findViewById(R.id.editText1);
        send = (Button) findViewById(R.id.button1);
        clear = (Button) findViewById(R.id.button2);
        output = (TextView) findViewById(R.id.textView1);

        //Connecting socket

        try{s=new Socket("192.168.11.154",8080);}
        catch(IOException err1){
            Log.d(msg, "ERROR: Could not connect!");
            Log.d(msg, msg, err1.getCause());
            Log.d(msg, err1.getMessage());
            Toast.makeText(this, "Connection error - restart the app", Toast.LENGTH_LONG).show();
            this.finish();
            }

        //Defining Buffers...

        try {
            outp = new PrintWriter(s.getOutputStream(), true);
            //LINE 78 ABOVE!!!!!!!
            inp = new BufferedReader(new InputStreamReader(s.getInputStream()));
            tmp = inp.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //Timer routines

        MyTimerTask myTask = new MyTimerTask();
        Timer myTimer = new Timer();
        myTimer.schedule(myTask, 0, 200);

        //Sending message
        //txt.getText()
        send.setOnClickListener(new OnClickListener(){
            public void onClick(View v){
                Log.d(msg, "Sending text...");
                //Sending text...
                outp.print(txt.getText().toString()+"\r\n");
                txt.setText("");
                }
            });
        clear.setOnClickListener(new OnClickListener(){
            public void onClick(View v){
                Log.d(msg, "Clearing...");
                output.setText("");
            }
        });
    }

    class MyTimerTask extends TimerTask{
        @Override
        public void run(){
            MyHandler.post(myRunnable);
        }
    }

    final Runnable myRunnable = new Runnable() {
        public void run() {
            //Buffer verifying..

    }};

    protected void onDestroy(){
        super.onDestroy();
        Log.d(msg, "CLOSING!");
        try {
            s.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

LogCat (updated so it shows the exception):
07-12 03:41:20.520: D/milkMsg(4646): Starting app...
07-12 03:41:20.520: D/milkMsg(4646): ERROR: Could not connect!
07-12 03:41:20.540: D/milkMsg(4646): milkMsg
07-12 03:41:20.540: D/milkMsg(4646): libcore.io.ErrnoException: socket failed: EACCES (Permission denied)
07-12 03:41:20.540: D/milkMsg(4646):    at libcore.io.Posix.socket(Native Method)
07-12 03:41:20.540: D/milkMsg(4646):    at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
07-12 03:41:20.540: D/milkMsg(4646):    at libcore.io.IoBridge.socket(IoBridge.java:568)
07-12 03:41:20.540: D/milkMsg(4646):    at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
07-12 03:41:20.540: D/milkMsg(4646):    at java.net.Socket.startupSocket(Socket.java:559)
07-12 03:41:20.540: D/milkMsg(4646):    at java.net.Socket.tryAllAddresses(Socket.java:127)
07-12 03:41:20.540: D/milkMsg(4646):    at java.net.Socket.<init>(Socket.java:177)
07-12 03:41:20.540: D/milkMsg(4646):    at java.net.Socket.<init>(Socket.java:149)
07-12 03:41:20.540: D/milkMsg(4646):    at com.milk.milkdispenser.MainActivity.onCreate(MainActivity.java:66)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.Activity.performCreate(Activity.java:5008)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-12 03:41:20.540: D/milkMsg(4646):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 03:41:20.540: D/milkMsg(4646):    at android.os.Looper.loop(Looper.java:137)
07-12 03:41:20.540: D/milkMsg(4646):    at android.app.ActivityThread.main(ActivityThread.java:4745)
07-12 03:41:20.540: D/milkMsg(4646):    at java.lang.reflect.Method.invokeNative(Native Method)
07-12 03:41:20.540: D/milkMsg(4646):    at java.lang.reflect.Method.invoke(Method.java:511)
07-12 03:41:20.540: D/milkMsg(4646):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-12 03:41:20.540: D/milkMsg(4646):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-12 03:41:20.540: D/milkMsg(4646):    at dalvik.system.NativeStart.main(Native Method)
07-12 03:41:20.540: D/milkMsg(4646): socket failed: EACCES (Permission denied)
07-12 03:41:20.610: D/AndroidRuntime(4646): Shutting down VM
07-12 03:41:20.610: W/dalvikvm(4646): threadid=1: thread exiting with uncaught exception (group=0x40c73300)
07-12 03:41:20.620: E/AndroidRuntime(4646): FATAL EXCEPTION: main
07-12 03:41:20.620: E/AndroidRuntime(4646): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.milk.milkdispenser/com.milk.milkdispenser.MainActivity}: java.lang.NullPointerException
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.os.Looper.loop(Looper.java:137)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.ActivityThread.main(ActivityThread.java:4745)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at java.lang.reflect.Method.invokeNative(Native Method)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at java.lang.reflect.Method.invoke(Method.java:511)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at dalvik.system.NativeStart.main(Native Method)
07-12 03:41:20.620: E/AndroidRuntime(4646): Caused by: java.lang.NullPointerException
07-12 03:41:20.620: E/AndroidRuntime(4646):     at com.milk.milkdispenser.MainActivity.onCreate(MainActivity.java:78)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.Activity.performCreate(Activity.java:5008)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
07-12 03:41:20.620: E/AndroidRuntime(4646):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
07-12 03:41:20.620: E/AndroidRuntime(4646):     ... 11 more

A:

libcore.io.ErrnoException: socket failed: EACCES (Permission denied)

07-12 03:41:20.540: D/milkMsg(4646):    at libcore.io.Posix.socket(Native Method)
First, you're missing the internet permission. Add to your manifest:
<uses-permission android:name="android.permission.INTERNET" />

Second, you're doing network operations on the UI thread. Move them to a background thread using e.g. AsyncTask. See How to fix android.os.NetworkOnMainThreadException?

