Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio error in build - Cause: startElement.getAttributeByName(QName("name")) must not be null

I want to create a spinner widget, and I added this to string.xml:

    <string-array name="options">
        <item>All Tasks</item>
        <item>Today's Tasks</item>
        <item>Tomorrow's Tasks</item>
        <item>Archived Tasks</item>
    </string-array>

and I adapted it:

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                R.array.options, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        spinner.setAdapter(adapter);

and I got a build error:

Cause: startElement.getAttributeByName(QName("name")) must not be null

How can I solve this?

like image 494
איתמר שיאון Avatar asked May 16 '21 15:05

איתמר שיאון


2 Answers

Special character like apostrophe(') are not allowed in xml directly Use can use escape sequences to get the desired result.

Replace: Today's by Today \ 's

Use a \ backslash symbol before apostrophe '

like image 102
Pawan Singh Harariya Avatar answered Oct 20 '22 07:10

Pawan Singh Harariya


In String.xml

replace 'String which you have entered' to String which you have entered

or simply remove ' ' these

like image 2
Nilesh Deshmukh Avatar answered Oct 20 '22 07:10

Nilesh Deshmukh