Error: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length

cpfp picture cpfp · Apr 5, 2013 · Viewed 39.2k times · Source

I got a problem with my android app. I got a button and and event associated , but when I click the first time an error appears

"spans cannot have zero lenght".

. But when I click the second time, the event onclick runs well.. look at my java code:

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    final Button selectAltitude = (Button) findViewById(R.id.buttonAltitude1);
    final Button selectAltitude2 = (Button) findViewById(R.id.buttonAltitude2); 
    
    selectAltitude2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view){
            
                String tempAlt = selectAltitude2.getText().toString();
                selectAltitude2.setText(selectAltitude.getText().toString());
                selectAltitude.setText(tempAlt);
        }
    });
    }

The xml code with the two buttons (a deprecated warning occurs):

 <?xml version="1.0" encoding="utf-8"?> 
<AbsoluteLayout
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent"
  android:background="@android:color/black"> 

<Button
        android:id="@+id/buttonAltitude1"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="39dp"
        android:layout_height="42dp"
        android:layout_marginLeft="250dp"
        android:layout_x="257dp"
        android:layout_y="419dp"
        android:background="@drawable/drawable1"
        android:focusableInTouchMode="true"
        android:gravity="center_vertical"
        android:includeFontPadding="false"
        android:linksClickable="true"
        android:minHeight="10dp"
        android:minWidth="64dp"
        android:paddingLeft="10dp"
        android:paddingRight="5dp"
        android:scrollHorizontally="true"
        android:text="@string/button_meters"
        android:textColor="@android:color/black"
        android:textSize="22sp"
        android:textStyle="bold" />
        
        <Button
            android:id="@+id/buttonAltitude2"
            style="?android:attr/buttonBarButtonStyle"
            android:layout_width="65dp"
            android:layout_height="42dp"
            android:layout_marginLeft="250dp"
            android:layout_x="295dp"
            android:layout_y="419dp"
            android:background="@drawable/drawable2"
            android:clickable="true"
            android:focusableInTouchMode="true"
            android:gravity="center_vertical"
            android:includeFontPadding="false"
            android:linksClickable="true"
            android:minHeight="10dp"
            android:minWidth="64dp"
            android:paddingLeft="15dp"
            android:paddingRight="5dp"
            android:scrollHorizontally="true"
            android:text="@string/button_feet"
            android:textColor="@android:color/black"
            android:textSize="25sp"
            android:textStyle="bold" />

When I click the first time Log cat interacts with:

04-06 20:01:39.865: I/Sensors(6946): sendDelay --- 200000000 04-06

20:01:39.865: D/SensorManager(6946): JNI - sendDelay 04-06

20:01:39.865: I/SensorManager(6946): Set normal delay = true 04-06

20:01:39.890: E/SpannableStringBuilder(6946): SPAN_EXCLUSIVE_EXCLUSIVE

spans cannot have a zero length 04-06 20:01:39.890:

E/SpannableStringBuilder(6946): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot

have a zero length

can you help ne?;)

Answer

Ajay S picture Ajay S · Apr 5, 2013

I have run into the same error entries in LogCat. In my case it's caused by the 3rd party keyboard I am using. When I change it back to Android keyboard, the error entry does not show up any more.

This is the most probable cause of this issue as there is also a bug report for SwiftKey:

http://support.swiftkey.net/forums/116693-2-bug-reports/suggestions/2994580-span-exclusive-exclusive-spans-cannot-have-a-zero-