spectrum icon indicating copy to clipboard operation
spectrum copied to clipboard

Error when using Spectrum in Android instrumented tests

Open RoRoche opened this issue 9 years ago • 2 comments
trafficstars

Just moving this file to this directory

when running this command: gradle connectedCheck I get the following error:

:app:transformClassesWithDexForDebugAndroidTestDex: Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
	UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
		at com.android.dx.command.dexer.Main.processClass(Main.java:775)
		at com.android.dx.command.dexer.Main.processFileBytes(Main.java:741)
		at com.android.dx.command.dexer.Main.access$1200(Main.java:88)
		at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1683)
		at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
		at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
		at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
		at com.android.dx.command.dexer.Main.processOne(Main.java:695)
		at com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)
		at com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)
		at com.android.dx.command.dexer.Main.run(Main.java:292)
		at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
		at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:173)
		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
		at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
		at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:476)
		at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
		at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
		at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
		at com.android.dx.command.dexer.Main.parseClass(Main.java:787)
		at com.android.dx.command.dexer.Main.access$1600(Main.java:88)
		at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1722)
		at com.android.dx.command.dexer.Main.processClass(Main.java:773)
		... 16 more

1 error; aborting
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

RoRoche avatar Nov 14 '16 10:11 RoRoche

It's cool to see Spectrum being used in new places. I don't think we've tried it with Android yet.

I know for a while you couldn't use Java 8 on older versions of the Android SDK. There may be some configuration you'll need to change to enable it. After some quick searching, I found this reference page:

https://developer.android.com/guide/platform/j8-jack.html

If you try those instructions to configure your Gradle build, does that help?

greghaskins avatar Nov 14 '16 12:11 greghaskins

OK, thanks.

I tried to add Jack to my projet. But it failed. Obviously, it seems that there is a problem when using both the Jack compiler and the Kotlin language:

  • https://blog.jetbrains.com/kotlin/2016/03/kotlins-android-roadmap/ (cf. the "Development Workflow" section)
  • https://youtrack.jetbrains.com/issue/KT-13275

RoRoche avatar Nov 16 '16 12:11 RoRoche