Skip to content

Running tests: workaround already added error

tleyden edited this page Oct 16, 2014 · 1 revision

Symptom

If you:

  • Run a single test via the Android Studio UI
  • Run ./gradlew connectedInstrumentTest or ./gradlew :CBLiteListener:connectedInstrumentTest on the command line

You will run into the error:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: LAcme/Serve/CgiServlet;
	at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
	at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
	.....

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Ljavax/servlet/Filter;
	at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
	at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
	.........
2 errors; aborting

at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandLineRunner.java:98)
at com.android.ide.common.internal.CommandLineRunner.runCmdLine(CommandLineRunner.java:69)
...

Root Cause

Issue 59592 in Android Studio.

Workaround #1 - Run only the CBLite tests

This will only work if you are running the tests via the command line

./gradlew :CBLite:connectedInstrumentTest

Workaround #2 - Short-circuit CBLListener in project

This is the best option if you are running the test via the Android Studio UI

Make the following two changes:

  • Go to the couchbase-lite-android/CouchbaseLiteProject directory
  • Edit settings.gradle to remove ':CBLiteListener' from the list
  • Edit CouchbaseLiteProject/dependencies-test.gradle to remove the line with compile project(':CBLiteListener')
Clone this wiki locally