android studio with Java compiler error: string too large to encode using UTF-8 written instead as 'STRING_TOO_LARGE'

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 09:10:19

For the time being, you can downgrade Gradle version to resolve this issue. Use gradle 3.1 version like 3.1.3 below.

  classpath 'com.android.tools.build:gradle:3.1.3'
ILMTL

I was stuck on this problem and read through this topic and no one provided a future solution. I did NOT want to revert back my Gradle. Therefore, here is the link to the updated dependencies https://github.com/stripe/stripe-android. Look for the "Android Studio (or Gradle)" section and you should see this "implementation 'com.stripe:stripe-android:8.1.0'" also you might need to add "-keep class com.stripe.android.** { *; }" if you are enabling minification in your build.gradle file.

Overall Stripe has stopped updating their own "Stripe docs" which can be found here. To give them credit their docs are helpful and should be read at least once, but be mindful that most of the docs are out date when I wrote this...

Hope this helps :)

I had encountered the same and fixed by clear the build cache .

You can use AAPT (from the android sdk/build-tools) to examine the APK and look for the offending string with the following command line (Linux):

// 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'

Which should point you to the culprit. In my case it was:

resource 0x7f0f015a com.example.app:string/eula: t=0x03 d=0x00000f10 (s=0x0008 r=0x00)
      (string8) "STRING_TOO_LARGE"

None of the above solutions worked for me. What ended up being the cause of the problem was, as it states, a String that was too large. Specifically, in my arrays.xml file under the values directory, I had some SVG arrays that were used within my app and commenting them out solved the issue.

If you know for certain you have some longer Strings somewhere in your resource directories (/res), check for any large Strings that may be lurking.

Also, this solution may help others but was not linked to in this thread.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!