My bad I was not calling XMPPTCPConnection.connect() before login.
Looks like there a few bugs in login methods
1. XMPPTCPConnection.login(userName, passWord) method does not throw a NotConnectedException even though XMPPTCPConnection.connect() was not called. It throws the exception mentioned in the original question.
2. XMPPTCPConnection.login() when called before calling XMPPTCPConnection.connect() throws the following inappropriate exception
java.lang.RuntimeException: Unable to create service sample.app.service.MessageService: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible()' on a null object reference
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2741)
at android.app.ActivityThread.access$1800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1361)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible()' on a null object reference
at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:297)
at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :395)
at sample.app.service.MessageService.onCreate(MessageService.java:131)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2731)
at android.app.ActivityThread.access$1800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1361)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)