I am running Android instrumentation tests on an emulator on Travis CI. The following test case invokes a helper method per method reference:
@Test
public void testGetLowEmissionZones_worksAtAll() {
// ...
lowEmissionZone.childZones.forEach(this::testChildZone);
// ...
}
private void testChildZone(@NonNull ChildZone childZone) {
// ...
}
When Travis CI executes this test it fails with a NoClassDefFoundError
:
ContentProviderTest > testGetLowEmissionZones_worksAtAll[test(AVD) - 4.3.1] FAILED
java.lang.NoClassDefFoundError: -$$Lambda$ContentProviderTest$He_xH9TsDaN0tZU8EqFP1CuQyAM
at ContentProviderTest.testLowEmissionZone(ContentProviderTest.java:151)
If I change the method invocation then there is no error:
@Test
public void testGetLowEmissionZones_worksAtAll() {
// ...
for (ChildZone childZone : lowEmissionZone.childZones) {
testChildZone(childZone);
}
// ...
}
I tried both openjdk8 and oraclejdk8, both fail.
How can I continue using method references?