How to solve error Command line is too long. Shorten command line for [Your test class] or also for Android JUnit default configuration.
Migration from linux to windows source code of an android project was not without problems.
I have experienced issues after updating libraries which comes in the form of the error Illegal Class File: Class Module-Info is Missing A Super Type. Class File version 53.
Now I was fixing an unit test execution problem under android studio. While running an unit test, I found the error below:
Command line is too long. Shorten command line for [your class test] or also for Android JUnit default configuration
I dont know if the problem is related to windows environment but what i am sure is that it’s pretty easy to solve it on linux or windows. Let’s see next, How to solve this problem.
Solution to resolve the error: Command line is too long. Shorten command line for [Your test class] or also for Android JUnit default configuration
To solve it, You have to go to the android studio settings and do the following steps :
- Run / debug configurations by clicking on the link below the error or by going through the main menu -> Run / debug configurations.
- At the option level we will change the content fields of Shorten command line. I mark it in blue in the image below
- Replace the field with this line in bold : classpath file -java WrapperClass classpathFile(args)
Normally after these 2 steps, everything would be settled after you push ok button. You will no longer find this error.
Additional tips
You may try to change the configuration for all android unit tests. I didn’t try it yet . If everything work fine dont do this.
You may select the tab Android JUnit to ensure that the configuration is applied to all content.