Open Megatronicus opened 1 month ago
Just reverted back to image: ^4.1.7 and still getting the same error. crop_your_image library didn't change from crop_your_image: ^1.0.2, I did flutter clean and flutter pub get and still getting the error, a half an hour everything was working great until I decided to update pubspec and then this started happening.
I don't know crop_your_image, but the Dart way to avoid naming conflicts is to use namespaced imports.
Thank you for answering but I'm not getting any indications of errors inside the classes where they're being used and I already have namespaced imports for image specifically, but not for crop_your_image. import 'package:crop_your_image/crop_your_image.dart'; import 'package:image/image.dart' as imglib;
No class is returning errors and this error message comes up during compile not when updating pubspec as I said above. The weird thing is even after downgrading back to image: ^4.1.7 I'm still getting the error even after flutter clean and flutter pub get. I don't get it.
I did flutter pub cache clean flutter clean flutter pub get
Still getting the same error even after reverting to the version that was working image: ^4.1.7 I even returned the whole pubspec from before and still getting the same error. Should I use a separate namespace for crop_your_image just like I'm using for image right now so that both have a separate namespace or is this ok?
import 'package:crop_your_image/crop_your_image.dart'; import 'package:image/image.dart' as imglib;
I don't get it why reverting back doesn't fix the error.
ImageFormat was added in 4.2.0. But the error you first posted indicated there is an import 'package:image/image.dart';
somewhere that was not namespaced.
I wish dart had code namespaces in addition to import namespaces.
I think the import is happening by crop_your_image.
Maybe I'll rename my class.
"I wish dart had code namespaces in addition to import namespaces." Yeah, that would be great.
I don't know what the best course of action would be but if you could rename the class and that would solve the problem that would be great. Please before you do go through all of that just check if this same problem occurs on your end too. I can't compile my project anymore because of this which means unless I find a fix I'll have to wait until you rename the class as it's an integral part of the app and thank you for making it. I just don't understand why reverting back didn't solve the problem, so there might be more going on here?
Reverting to image < 4.2.0 should work because there is no ImageFormat enum before then. So it must be a cache ghost haunting you.
I'm surprised issues like this don't come up more often. It's not like I was super creative with my naming "Image".
To be fare, I wrote this over 10 years ago, before Dart was even 1.0. There was no Flutter back then, and only a handful of libraries on pub. And naming things is hard.
"Reverting to image < 4.2.0 should work because there is no ImageFormat enum before then. So it must be a cache ghost haunting you."
I'm going to try a couple of things, will report back, must be the cache yeah
"I'm surprised issues like this don't come up more often. It's not like I was super creative with my naming "Image".
To be fare, I wrote this over 10 years ago, before Dart was even 1.0. There was no Flutter back then, and only a handful of libraries on pub. And naming things is hard."
Haha, the naming is precise and on point, great job on that =) but yeah I was surprised when I saw the name that they allowed that and they didn't take it for themselves for some official library, it's good though still that naming doesn't come up that often as a problem, I seem to have a propensity for encountering problems though so here we are, lol. Will report back soon about the cache and reverting back.
Well, I tried Invalidate Caches, didn't help, then tried to delete C:\Users\Computer.gradle\caches, now I get this
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong: java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to create Jar file C:\Users\Computer.gradle\caches\jars-9\842fa7fdff1ae2bf257faa84bc187276\gradle-1.0.0.jar.
org.gradle.api.GradleException: Failed to create Jar file C:\Users\Computer.gradle\caches\jars-9\842fa7fdff1ae2bf257faa84bc187276\gradle-1.0.0.jar.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 4s
Probably shouldn't have done that. I'll probably reinstall Android Studio and flutter and write back tomorrow.
I would think it's a pub cache thing rather than a gradle thing, but I have very minimal knowledge of gradle, or flutter.
$HOME/. pub-cache
(on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache
(on Windows). If you haven't already, maybe go through the directories in there and delete anything that is image-4.2.0.
Or maybe change your pubspec to use a specific version of image. I only know enough about pub to be dangerous.
I reinstalled Android Studio, still got the same error. I tried making a new project, imported image and crop_your_image and a class where I'm using it and there's no conflict in the new project so now I have no clue what's going on.
The easiest fix would be to fix crop_your_image. I'll file an issue over there, https://github.com/chooyan-eng/crop_your_image/issues/157. Hopefully they can put out a quick fix by namespacing the image import in their package. I could rename the enum on my end, but I would probably make other people angry.
It seems crop_your_image users encountered the same conflict
[https://github.com/chooyan-eng/crop_your_image/issues/155]
the developer already published a new version 1.1.0, for some reason pubspec recommends 1.0.2, it's not until I went to pubdev that I saw there was a 1.1.0 version there. Now there's no more conflict. I'm getting another error now not connected to this library, so onto solving. Thank you for responding so fast! Best regards.
I'm glad he got a fix out, and I'm sorry you're having so many troubles. Package management is a dark art, I don't think anyone's really gotten it figured out. And I'm prone to breaking things, an unfortunate result that I haven't even done any Dart programming in years other than supporting these libraries. I do enjoy working on them though, and I'm glad people find them useful.
/C:/Users/Computer/AppData/Local/Pub/Cache/hosted/pub.dev/crop_your_image-1.0.2/lib/src/logic/cropper/image_image_cropper.dart:13:1: Error: 'ImageFormat' is imported from both 'package:crop_your_image/src/logic/format_detector/format.dart' and 'package:image/src/formats/image_format.dart'. import 'package:image/image.dart'; ^^^^^^^^^^^ /C:/Users/Computer/AppData/Local/Pub/Cache/hosted/pub.dev/crop_your_image-1.0.2/lib/src/logic/cropper/image_image_cropper.dart:24:32: Error: Not a constant expression. ImageFormat outputFormat = ImageFormat.jpeg, ^^^^^^^^^^^ /C:/Users/Computer/AppData/Local/Pub/Cache/hosted/pub.dev/crop_your_image-1.0.2/lib/src/logic/cropper/image_image_cropper.dart:24:32: Error: 'ImageFormat' is imported from both 'package:crop_your_image/src/logic/format_detector/format.dart' and 'package:image/src/formats/image_format.dart'. ImageFormat outputFormat = ImageFormat.jpeg, ^^^^^^^^^^^ Target kernel_snapshot failed: Exception
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Try:
Get more help at https://help.gradle.org
BUILD FAILED in 1m 21s Error: Gradle task assembleDebug failed with exit code 1
Error appeared when trying to get dependencies to update pubspec
when using
image: ^4.2.0
with
crop_your_image: ^1.0.2
There was no conflict in the version image: ^4.1.7