-
Notifications
You must be signed in to change notification settings - Fork 743
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
NullPointerException in 2.1.1 in Android compilation #771
Comments
How are you invoking Error Prone? It looks like you aren't using the version of javac we distribute. |
It's just an Android Gradle project. Is there anything specific I need to add beyond the plugin? |
@tbroyer FYI I think |
I'll try and make a self-contained example today. |
I have solved this - it's caused by Android projects using Java 7 (but with retrofit lambda etc.) and Error Prone > 2.0.5 requiring Java 8. Or at least when I downgraded to 2.0.5 it all worked again. Unfortunately that's awkward as there's fixes post 2.0.5 which fix other issues. Guess I won't be using it until I upgrade to Android Studio 3. |
This should be reopened. As I mention in the referenced issue I see the same problem on an Android project regardless of using Java 7 or 8. It's a matter of using errorprone 2.0.19 vs. 2.0.20. Minimal sample project for reproduction here: https://github.com/bubenheimer/errorpronebug A few more details in the referenced issue. |
I solved this problem by updating error-prone to the newest version 2.1.2. update: |
The sample project build continues to fail with 2.1.2. |
I removed the options.compilerArgs += ["-Xep:MissingCasesInEnumSwitch:WARN"].And the problem does not appear |
The issue remains present with Android Studio 3.1.0-beta2, the new Android databinding compiler, and errorprone 2.2.0. Errorprone seems incompatible with databinding, for all versions after 2.0.19. Is there any plan to change this? |
Same issue here. My gradle in Android Studio 3.0.1 using
|
Adding the following in
|
Can anything be done to address this issue? The reliable "enableSeparateAnnotationProcessing" flag workaround I described above is being removed. Or is someone able to exert their clout on the Android Developer Tools team to keep the flag around, perhaps with a different name, to keep errorprone usable on Android? https://issuetracker.google.com/issues/115774858 |
Is this still reproducible when using recent versions of Error Prone / databinding / gradle / the Android plugin, and running on JDK 11? I think the |
Android Studio uses OpenJDK 9 AFAIK, so I don't think I'd be able to test out this theory anytime soon. |
OpenJDK 8, actually |
Thanks. Are you seeing the same issue with the latest version of databinding? I started trying to update versions in https://github.com/bubenheimer/errorpronebug but am less familiar with the Android/databinding side of this. |
Yes, and I don't think it is tied to databinding, that just brings it out more easily. Pretty sure I have Gradle modules that break without databinding. The issue is intermittent in nature. Thank you for looking into it again. I've updated the project to all the latest dependencies and pushed it. The compiler crash has remained the same for me. |
Thanks. I can still reproduce:
... but it builds cleanly with JDK 11 (and the fix for JDK-8187950.)
|
Nice! |
Does using JDK 11 solve the problem you're seeing? I didn't try getting it working with Android Studio, just command line gradle. |
It may be possible to do Android builds with JDK 11, but it would be hardly supported from the Android team's side right now, so chances are it would be a head-splitting migraine to use for real work. Android Studio comes with OpenJDK 8, that is what is officially supported. I'm guessing Android will at some point support JDK 11, but there is no official timeline out. Possible that June 3 will bring some news. |
Android Studio is switching to 11 because the platform on which it's based, IntelliJ, switched to only offer 11 in 2020.1. Previously you could run either on 8 or 11. Because AS will solely run on 11, this means the actual build system (usually referred to as AGP, that is, the Android Gradle Plugin) will also need to fully work on JDK 11. For what it's worth, I'm using JDK 14 for Android builds and it's actually working fine today for the most part. It's third-party tools that sometimes break because of the increasing VM restrictions on reflection. What doesn't work is using a source version higher than 8 because Android builds rely on the bootclasspath which doesn't exist anymore once your source version is 9 or higher. That, too, will be mitigating by switching to a module for at least the framework APIs. |
Thanks @JakeWharton! It sounds like using JDK 11 or newer is the way to go. The javac fix for the underlying issue is unlikely to get backported to earlier versions at this point, and I don't see any good options for mitigating this in Error Prone. |
I can't see an obvious check that's failing here. This is compiling an Android application.
The text was updated successfully, but these errors were encountered: