Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STRING_TOO_LARGE String in Kotlin

When I added plugins to support the Kotlin in my project, Then after it read large string from my project's string.xml file. It gives me following error below.

error: string too large to encode using UTF-8 written instead as 'STRING_TOO_LARGE'.

like image 597
Anil Ugale Avatar asked May 10 '18 10:05

Anil Ugale


People also ask

How do you manipulate string in Kotlin?

Kotlin strings are mostly similar to Java strings but has some new added functionalities. Kotlin strings are also immutable in nature means we can not change elements and length of the String. To declare a string in Kotlin, we need to use double quotes(” “), single quotes are not allowed to define Strings.

How do you get char from string in Kotlin?

Using first() function The standard approach to converting a string to a char in Kotlin is to use the first() function, which returns the first index's element.

How do I print the length of a string in Kotlin?

To find the length of string in Kotlin language, you can use String. length property. String. length property returns the number of characters in the string.

What are the strings available in Kotlin?

Kotlin has two types of string literals: Escaped String. Raw String.


2 Answers

This is an issue with the gradle plugin.

If you upgrade the plugin to 3.3.0-alpha06 or later and upgrade gradle to 4.9 it should work. It's not ideal since it is alpha, but it fixed the issue for me.

Add <?xml version="1.0" encoding="utf-8"?> to the top of any resource .xml file that is missing it.

like image 90
Lancelittle Avatar answered Oct 22 '22 01:10

Lancelittle


When working with vector resources, you simply need to find and divide a string that is longer than 32kb, in my case, it was a complex path which I simplified a little to match the criterion of 32kb

like image 8
user10433417 Avatar answered Oct 22 '22 01:10

user10433417