In Android Studio imported a new project. During startup, a compilation error occurs with the following content: error: string to large to encode using UTF-8 written instead as 'STRING_TOO_LARGE'
The network for this information found only 2 links, namely, HERE and EGS , which have the same problem, but there is really no solution. In principle, by the content of the error, it is clear that there was an error in coding large strings using UTF-8.
There are no such strings in strings.xml .
In the drawabl e folder there are a lot of files in which almost all files (and there are a lot of them) have warnings like: Very long vector path (5745 characters), which is bad for performance. Consider reducing, remove minor details or rasterising vector.

Be so kind as to tell me what methods you can use to get rid of this error. Thank.

  • one
    Try running the build with --debug or --stacktrace to see which file is causing the problem - Valeriy Andrikeev
  • @ v.andrikeev thanks, your hint was very helpful. - Tomas

2 answers 2

Found a solution to the problem, thanks to the hint of the user v.andrikee v. The sequence of actions is as follows:

  1. Run the assembly with the parameters - debug And - stacktrace . How to do this, look here .
  2. In the Build tab (in the lower part of the window) instead of a single line : error: string to large to encode using UTF-8 written instead as 'STRING_TOO_LARGE' . When you click on the Run Build C: ... field (an exclamation mark in a red circle), a stack trace should appear with detailed information about the compilation error.
  3. In my case, the root problem in the stack trace was the following:

    Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: okhttp3.internal.ws.RealWebSocket $ 1 at com.android.tools.r8.utils.Reporter.failIfPendingErrors (Reporter.java:116 ) at com.android.tools.r8.utils.Reporter.fatalError (Reporter.java:74) at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler (ExceptionUtils.java:59) ... 50 more

    In short, 2 libraries were connected to the project: okhttp3-3.10.0 and okhttp3-ws-3.4.1 and they had a version conflict associated with the okhttp3.internal.ws file. RealWebSocket .

  4. Since the project used both libraries, it was necessary to save them. To resolve library conflicts, you need to add the following code snippet to Gradle (app) (picked up here ):

    configurations.all {
    exclude module: 'okhttp-ws'
    }

  5. Rebuild the project and enjoy the launch version :)

    from the error it is clear that the error occurs due to too long pathData of the vectors.

    I came up with 3 options: the easiest (but this is not accurate): convert vector images to png / jpg and use them.

    or use other vector images or not use such complex vector images

    • 1. These vector images are already used. 2. I do not have other vector images. 3. There is a lot to convert ... - Tomas