E/spannablestringbuilder: span_exclusive_exclusive spans cannot have a zero length

coderlegi0n

CoderLegion

Posted on March 16, 2022

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.

šŸ’– šŸ’Ŗ šŸ™… šŸš©
coderlegi0n
CoderLegion

Posted on March 16, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related