Edwin
Edwin

Reputation: 805

string does not contain a valid string resource. Android Studio

I get this error message:

> Task :app:mergeDebugResources
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:51:4: Failed to flatten XML for resource 'Turn_Your_Ideas_into_Product' with error: Attempting to flatten xml with unfinished spans.
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:51:4: string/Turn_Your_Ideas_into_Product does not contain a valid string resource.
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:65:4: Failed to flatten XML for resource 'Write_a_Short_Book' with error: Attempting to flatten xml with unfinished spans.
C:\Users\user\Desktop\Kotlin Projects\Projects\10000Months\app\src\main\res\values\strings.xml:65:4: string/Write_a_Short_Book does not contain a valid string resource.

whenever I use these strings (below) in values->strings in Android Studio. Please take a look at them what should I add or remove;

<!--Record Your Conversations-->
    <string name="Record_Your_Conversations">
        <font size="17">Record Your Conversations</font>\n
        <font size="13">Is there a subject that you\'re exceptional knowledgeable about? Or even a subject that you\'re really interested in diving into a little deeper? Are you a good listener?…</font>
    </string>


<!--Write a Short Book-->
    <string name="Write_a_Short_Book">
        <font size="17">Write a Short Book</font>\n
        <font size="13">Writing a book is not easy, but we\'ll assist you, and this is especially good avenue to take if you're not interested in audio, video, or physical products…</font>
    </string>

Edit:

I have other similar strings, like this one:


<!--Teach People What You Know-->
    <string name="Teach_People_What_You_Know">
        <font size="17">Teach People What You Know</font>\n
        <font size="13">I bet you know things. Things that other people don\'t know. Music, sales, yoga etc. These are things people are constantly learning…</font>
    </string>

It works for them, I don't know what is wrong with the other 2 strings..

Thanks for your help..

Upvotes: 3

Views: 3043

Answers (2)

cactustictacs
cactustictacs

Reputation: 19622

There's your problem, you've got an unescaped quote in Write_a_Short_Book:

take if you're not interested

You didn't post Turn_Your_Ideas_into_Product (the other one in your error log) but it's probably the same issue

Upvotes: 2

makis.k
makis.k

Reputation: 462

You cannot use html like that in the strings.xml. You should either use CDATA[] like below:

<string name="string_html"><![CDATA[<b>Html text</b>]]></string> 

or otherwise like below example:

<string name="string_html">&lt;b&gt;Html text&lt;br&gt;&lt;font color=\"#fe2e68\"&gt;text example&lt;/font&gt;&lt;/b&gt;</string>

Upvotes: 0

Related Questions