samedi 25 juin 2016

Why only instrumented unit test builds are failing with mobile:transformClassesWithDexForDebug

I am trying to write a simple android instrumented unit test to test my testing setup. I have a very basic code as below:

ApplicationTest.java

public class ApplicationTest extends ApplicationTestCase<Application> {
  public ApplicationTest() {
    super(Application.class);
  }
}

Gradle

testCompile 'junit:junit:4.12'

When i try to run this test the gradle build is failing with following error:

Error:Execution failed for task ':mobile:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

As far i understand it's says i have reached the 64k limit. But my app is something small. And i haven't added dependency to many external libraries either.

Another thing i found is that i am able to do normal debug builds without any problem. I am not required to do Multidex in that case. Then why am i shown this error only when i am trying to do the automated test? How can i solve it and make this test happen?

Aucun commentaire:

Enregistrer un commentaire