Reputation: 1098
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'.
Upvotes: 21
Views: 26662
Reputation: 5191
This is not really a Kotlin question, it's related to the build tools. This didn't happen on Build Tools 27 (Gradle 3.1) but happened for me after upgrading to Build Tools 28 (Gradle 3.2).
The solution is posted here STRING_TOO_LARGE Java compiler error.
You can use AAPT (from the android sdk/build-tools) to examine the APK and look for the offending string:
// Linux/Mac
./aapt dump --values resources MyAppName-regular-debug.apk | grep -B 1 'STRING_TOO_LARGE'
// Windows
aapt dump --values resources MyAppName-regular-debug.apk | grep -B 1 'STRING_TOO_LARGE'
Upvotes: 5
Reputation: 3802
Go to File > Invalidate Caches/Restart . This solved my problem.
Upvotes: 2
Reputation: 1139
It seems that a common cause for this is having a Stripe in your app/build.gradle, seems it has a vector file being read as a string longer than 32kB.
To solve this, change your stripe version to something after 7.0.0, which is where they fixed it. Current version of Stripe is 8.1.0.
Upvotes: 5
Reputation: 101
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
Upvotes: 10
Reputation: 133
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.
Upvotes: 9