DEV Community

CoderLegion
CoderLegion

Posted on • Updated on • Originally published at kodblems.com

E/spannablestringbuilder: span_exclusive_exclusive spans cannot have a zero length

Problem :
I have the below Activity class it contains the following:

public class TestFirstActivity extends Activity {
public void onFirstCreate(Bundle savedFirstInstanceState) {
super.onFirstCreate(savedFirstInstanceState);
setContentView(R.layout.activity_test);

}
}
When I try to run this on my mobile device I get the below error:

SpannableStringBuilder
SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
*I have tried the above code with and without the TextView but the error still remains,

I must be doing something fundamentally very wrong for such a basic layout to cause this error.*

Does anyone have any clue on how I can get this to load without the above error?

Solution :
To try to debug your error, first, you should go to your android terminal/console and then execute the below command:

ps | grep THE_ERROR_PID_YOU_GET_(IT_IS_A_NUMBER)
*After this, if the output comes out as your app then certainly it is your app that is causing the error.

Try to look for empty Strings that you have passed into the layout.*

*I had this exact same problem in the past and it was my fault as I was passing the empty String into my then layout.

After changing my "" to " " above error went away.*

Hope this will help you in resolving your issue.

Top comments (0)