Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dagger 2.10-rc1 won't compile in Android #593

Closed
emarc-m opened this issue Feb 23, 2017 · 25 comments
Closed

Dagger 2.10-rc1 won't compile in Android #593

emarc-m opened this issue Feb 23, 2017 · 25 comments

Comments

@emarc-m
Copy link

emarc-m commented Feb 23, 2017

I wanted to try the new features for activity and fragment injection in dagger.android but I get this gradle error stack trace when trying to update from v2.9 -> 2.10-rc1

`Dex: 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:560)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:376)
at com.android.dx.command.dexer.Main.run(Main.java:290)
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

warning: Ignoring InnerClasses attribute for an anonymous inner class
(autovalue.shaded.org.apache.commons.lang.builder.HashCodeBuilder$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(autovalue.shaded.org.apache.commons.lang.builder.ToStringStyle$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is not an inner class.
Dex: 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:587)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:376)
at com.android.dx.command.dexer.Main.run(Main.java:290)
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
`

is 2.10-rc1 not compatible with Android or is there configuration I need do?

Thanks.

@LuigiPapino
Copy link

are you using retrolambda?

@JakeWharton
Copy link

It's not a Retrolambda problem. The classfiles in the artifact were compiled with a target of Java 8.

@ronshapiro
Copy link

This should be fixed in rc2 shortly

@LuigiPapino
Copy link

Perfect, thanks very much

@bubenheimer
Copy link

@ronshapiro - once RC2 is out, could you share how you built it? (Unless it's more obvious at that point.) I tried and failed to build the dagger artifacts with a target of JDK 1.7, to better evaluate RC1.

@ronshapiro
Copy link

ronshapiro commented Feb 23, 2017 via email

@bubenheimer
Copy link

Thanks - pretty sure that's what I did in terms of bazel build. It generated 1.8 artifacts. Had trouble figuring out how make Bazel generate 1.7 targets, but once I settled for passing through javac command-line options via --javacopt, I was not able to build dependencies that were using Java 8 source style. Hoping it will change with RC2.

@bubenheimer
Copy link

I think I found my error. I mistakenly thought that my hand-built Dagger Android libraries were the issue, when the real problem was the official plain dagger RC1 artifact from Maven. Thanks for the pointer!

@Modulo216
Copy link

Any update on when we can expect RC2?

@ronshapiro
Copy link

@Modulo216 I'm building it right now actually :)

@ronshapiro
Copy link

Should be live (but Sonatype seems slow today)

@JonathanMerritt
Copy link

I've been having this same issue.

I tested out RC2 and unfortunately the issue has persisted. I reverted to using a local android package and 2.9. However if you need more info for the setup or logs just let me know.

@JakeWharton
Copy link

JakeWharton commented Mar 4, 2017 via email

@JonathanMerritt
Copy link

@JakeWharton I apologise if I sound uninformed but I'm very much a novice still...

You're saying the new build isn't J8 ready basically? Parsing byte code is well beyond my understanding sorry.

@JakeWharton
Copy link

JakeWharton commented Mar 4, 2017 via email

@JonathanMerritt
Copy link

Yes it gives me the same error as the OP.

'Dec cannot parse version 52... ... targetCompatibilty=1.7...'

My setup is similar as well, I'm using retroLambda etc...

I'll be happy to make a fresh project and get what info you may need.

@JakeWharton
Copy link

JakeWharton commented Mar 4, 2017 via email

@JonathanMerritt
Copy link

`build.gradle
...
dependencies {
def dagger2 = '2.10-rc2'

compile "com.google.dagger:/dagger:${dagger2}"
compile "com.google.dagger:dagger-android:${dagger2}"
compile "com.google.dagger:dagger-android:support:${dagger2}"

annotationProcessor "com.google.dagger:dagger-compiler:${dagger2}"

annotationProcessor "com.google.dagger:dagger-android:processor${dagger2}" - Unsure if this is needed, error is the same with or without however.
`

@JakeWharton
Copy link

That syntax is invalid so I suspect your build is not actually picking up the new artifacts. Try this:

compile "com.google.dagger:dagger:${dagger2}"
compile "com.google.dagger:dagger-android:${dagger2}"
compile "com.google.dagger:dagger-android-support:${dagger2}"

annotationProcessor "com.google.dagger:dagger-compiler:${dagger2}"
annotationProcessor "com.google.dagger:dagger-android-processor:${dagger2}"

@JonathanMerritt
Copy link

Thank you. I will report back as soon as I can. That must be the issue though. Surprised the way I was doing it picked up at all...

That / in there was because I didn't know how to stop the little dagger icon from replacing the word.

Anyway, I'll be able to test this again soon and I'll let you know, thank you again.

@JonathanMerritt
Copy link

@JakeWharton

All set. That was exactly it. You're like a laser with this stuff. Thank you for this, and all you've taught me too.

Sorry for all the notifications everyone.

@numerouno979
Copy link

numerouno979 commented May 18, 2017

Still facing this issue with 2.9 artifact deployed on maven central.
Attached is screen shot of manifest.mf file
dagger2 9-manifest mf

@ronshapiro
Copy link

What about 2.11-rc2?

@numerouno979
Copy link

numerouno979 commented May 18, 2017

Still reproducible with '2.11-rc2', even with 2.10

@rakshakhegde
Copy link

rakshakhegde commented May 18, 2017

I'm using 2.11-rc2 in this repo and it works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants