-
Notifications
You must be signed in to change notification settings - Fork 447
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
Retrolambda breaks lint #96
Comments
I found this bug too this morning and the problem seems related to the new lint version. |
@pietrodev could you give an example of what dependency you changed to use that version of lint? I wasn't aware we could specify different versions. |
Yes, of course all gradle modules must specify the version for every dependencies. I didn't know at the beginning where to find that one, but I searched the .gradle directory for files containing lint and I found this one:
Yours may be a different version. Inside the file you find: <dependency org="com.android.tools.lint" name="lint" rev="24.1.0" force="true" conf="runtime->compile(*),runtime(*),master(*)"/> Just change the 24.1.0. to 24.0.0 and recompile |
@pietrodev just to note, lint has never worked with retrolambda, it is just now failing loudly. Before it would silently skip the rest of your file if it encountered a lambda. See #69. |
@evant Thanks, I didn't know this. |
Well, unreadable source files, class files should work since it would be reading the output from retrolambda. (lint does both) |
I think I may have come up with a solution to this. Basically I forked lombok ast used by lint and modified it a bit to not fail on java 8 features. With a little gradle magic it's easy to replace with my version. Let me know what you think! https://github.com/evant/android-retrolambda-lombok |
Does it check the code in these blocks or does it just skip them while
|
It just turns the "lambda" node into a "statement" node which is good enough for lint to detect unused resources and such. It would be technically be better to fully implement the new ast nodes, but since none of the lint passes expect them, cheating seems to be good enough. |
Interesting. Same result for method references as well?
|
Method references are replaced with "null". Both these choices may have to be revisited if it trips up any of the lints, but I haven't seen any issues with might light testing. |
Cool, I'll do some thorough testing as well and report in on the new repo |
Any resolution to this? I am getting the same loud errors. Thanks. |
@evant I can't get that routine to work (android-retrolambda-lombok). It still outputs all the errors although I've configured the plugin correctly under the buildscript dependencies. You say "run gradle with java 1.8". How do I ensure that? |
"run gradle with java 1.8" just means that you have JAVA_HOME or your jdk path in android studio set to java 8. Are you sure you have applied the configuration to all the buildscript blocks in your project? You can use task printBuildScriptClasspath << {
println project.buildscript.configurations.classpath.asPath
} to print out the classpath and ensure it's properly removing the original dependency and adding this one. |
I'm still having issues with this. Here is my build output:
Here is the output of
Let me know if there's anything else I can provide. |
Um, you sure you don't actually have lint errors? You'd normally get a stacktrace like posted in this issue when it hits a file with lamdba instead of it succeeding like that. |
Perhaps you are correct. I just saw build failed but this did remove the original stack trace. I'll report back when I figure it out but I don't think this is your problem. Thanks a lot! Edit: Yes, other build issues. Thanks so much again for the help! |
Is there any workaround? Since I don't want to give Lint up. |
@vanniktech Use https://github.com/evant/android-retrolambda-lombok project mentioned above. It worked out well for me. |
Related to issue evant/gradle-retrolambda#96.
Workaround works great, thanks. I've also filed this as http://b.android.com/200887 since it doesn't seem to have been reported to the Android tools team so far. |
Hopefully we can remove projectlombok when evant/gradle-retrolambda#96 is fixed. Signed-off-by: Ichizo Umehara <iumehara@pivotal.io>
I don't fully get it. Is is somehow possible to the inspection about unused strings, layouts and drawables correct? |
This workaround does not fixes false-positives on Android Studio which has bundled lombok jar. |
This error happened with JDK 7, how can i solve it ? |
Puzzled...anyone see what's wrong my classpath? Looks like it includes the new lombok.ast from running the :printBuildScriptClasspath task and I'm running Java 8_102 because I know JDK7 doesn't work with this workaround: The build script looks right too :-(
I still get:
|
FYI, the 2.2.0-beta1 plugin seems to fix not being able to see unused resources even though it still spews lots of errors out. It also gives random "unsupported major.minor version 52.0" errors so I wouldn't upgrade to it yet, but there's some hope of having a useful lint again for those of us who couldn't get the workaround working... |
the problem is still reproducible when using retrolambda-lombok.
lint xml contains try with resources ignore statement but I still get problems like:
Additional lint config is the following:
Could you please tell where the problem can be? |
The https://github.com/evant/android-retrolambda-lombok script did not work for me. I suspect that may be because my resources are being used in Kotlin via Anko. The anko layouts are in Kotlin lambdas - I have no idea how Kotlin/retrolambda processes those. Here's an example:
|
@oliverdain I don't think this is related to Kotlin. We have a pure Java project and it doesn't work either |
I've confirmed that this issue is caused by having custom lint rules that use the old and deprecated lombok AST API. If you migrate all your custom lint rules to the PSI API, then the errors go away. |
I also think that Timber has custom lint rules that are using the old format. (Haven't checked it though) |
@vanniktech that's right. We don't use timber, but if anyone wants to send a PR, that would be great :) |
@vanniktech @felipecsl Timber dev branch has this issue fixed, but it hasn't been picked up by the latest release yet. In the meantime, I'm using jitpack to pull it in. Confirmed that this fixes all my lombok lint issues. 👍 |
Related to #69, but figured I'd open a more general issue for discussion and the hope that someone has come up with a creative solution to this.
As of right now, the version of Lombok used by the linter doesn't support lambdas, which causes it to fall over during linting (example output below). This is a dealbreaker for many, as lint is an important tool for catching issues and can also double back as a data generator for scripting tools (like removing unused resources).
An ideal solution would probably be a recompiled version of the linter with an updated Lombok dependency that supports Java 8.
A possible alternative could be adding a rule to somehow skip LambdaExpression nodes in the AST during processing, though I think this would come at the expense of knowing anything inside the lambda.
Example output of the exception encountered:
The text was updated successfully, but these errors were encountered: