Error: constant string too long


(GentleMint) #1

When run “gradlew build”, I encountered “error: constant string too long” for one of my java Class A.java.
A.java is my Unit Test Class and it contains testing data string which is very long. And there is no error when compile in Eclipse.
How can I solve this error for Gradle?


(Stefan Oehme) #2

That’s not a Gradle specific error, but just a limitation of Java. You could simply put your test data in a file and read that in the test instead of putting a huge String into your test class.


(GentleMint) #3

Thanks very much. It’s a general Java compilation problem. I used another way to solve the problem: using StringBuilder instead of the String for the long constant string.