cordova-plugin-file
cordova-plugin-file copied to clipboard
Gradle 6.5 - "Could not find method leftShift()"
Bug Report
gradle.extras fail with gradle 6.5
Problem
When using gradle 6.5 to build a cordova Android app, the build crashes with the following error:
"A problem occurred evaluating project ':app'. Could not find method leftShift() for arguments [build_extras_iirp9rj48r4etl69rhtwhtw1$_run_closure1$_closure2@49b383e8] > on task ':app:cdvCreateAssetManifest' of type org.gradle.api.DefaultTask."
What is expected to happen?
It is expected to build without issues.
What does actually happen?
See problem.
Information
This seems to relate to the fact that the << - notation is deprecated in newer gradle versions. https://stackoverflow.com/questions/55793095/could-not-find-method-leftshift-for-arguments-after-updating-studio-3-4
Command or Code
building a cordova app to Android
Environment, Platform, Device
Fresh installed Ubuntu with the Angular/Cordova stack.
Version information
Angular: 10.0.14 Cordova: 10 cordova-plugin-file: 6.0.2 Gradle 6.5
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
It appears to be caused by https://github.com/apache/cordova-plugin-file/blob/2bbbb8487194531cf82b314274da4017342f9def/src/android/build-extras.gradle#L24
However I don't see anywhere how this gradle file is included, and for me this gradle file doesn't actually run. Would you mind sharing a sample reproduction app?
@breautek I think you have to add it manually according to the instructions here: https://github.com/apache/cordova-plugin-file#slow-recursive-operations-for-android_asset
Listing asset directories is really slow on Android. You can speed it up though, by adding src/android/build-extras.gradle to the root of your android project (also requires [email protected] or greater).
I think this is a low hanging fruit to fix - any Hacktoberfest volunteers here? :)
I know how to fix it, honestly. Just remove the << and wrap the whole block inside a doLast { } - block. I'm sorry if the solution was unclear, it was on the link I sent.
and @steinjak is right. The script is added manually. It is possible to make changes to it locally and using this version, but I felt it was in good sport to have a non-deprecated version of the script included.
I see. I wonder if there is any reason why this is an opt-in.
Imo the plugin should just include the gradle reference automatically.
I know how to fix it, honestly. Just remove the << and wrap the whole block inside a doLast { } - block. I'm sorry if the solution was unclear, it was on the link I sent.
and @steinjak is right. The script is added manually. It is possible to make changes to it locally and using this version, but I felt it was in good sport to have a non-deprecated version of the script included.
PR is welcome, I just wanted to make sure the code that appeared to be offending was actually something used.