SocketMobile / capturesdk_flutter

Public snapshot for flutter sdk
MIT License
3 stars 1 forks source link

Compile failed related to AppInfo class #7

Closed nneuberger1 closed 9 months ago

nneuberger1 commented 12 months ago

I get the following error trying to compile with the latest code. I recently did a flutter upgrade to get updates to the latest versions on Android Studio, Xcode versions, and flutter versions.

Could not build the precompiled application for the device. Error (Xcode): ../../../../.pub-cache/hosted/pub.dev/capturesdk_flutter-1.4.17/lib/classes/app_info.freezed.dart:25:12: Error: No named parameter with the name 'includeToJson'.

My AppInfo is created like the following:

return AppInfo( appIdAndroid: '', appIdIos: 'my-app-bundle-id-here', appKeyAndroid: '', appKeyIos: 'my-app-key-ios-here', developerId: 'my-developer-id-here');

I tried the syntax here, but no joy: https://docs.socketmobile.com/captureflutter/en/latest/gettingStarted.html#sdk-installation

I'm looking at the syntax of this, but not sure if what I put above lines up properly with this syntax? capturesdk_flutter/lib/classes/app_info.dart

@freezed class AppInfo with _$AppInfo { const factory AppInfo({ @JsonKey(name: 'appId') String? appIdAndroid, // ignore: invalid_annotation_target @JsonKey(includeToJson: false) String? appIdIos, // ignore: invalid_annotation_target @JsonKey(name: 'appKey') String? appKeyAndroid, // ignore: invalid_annotation_target @JsonKey(includeToJson: false) String? appKeyIos, // ignore: invalid_annotation_target required String developerId, }) = _AppInfo;

factory AppInfo.fromJson(Map<String, Object?> json) => _$AppInfoFromJson(json); }

I'm using the following version in my pub spec.yaml.

capturesdk_flutter: 1.4.17

Here's a flutter doctor output:

[✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.1 23B81 darwin-arm64, locale en-US) • Flutter version 3.16.0 on channel stable at /Users/nickneuberger/apps/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision db7ef5bf9f (11 days ago), 2023-11-15 11:25:44 -0800 • Engine revision 74d16627b9 • Dart version 3.2.0 • DevTools version 2.28.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/nickneuberger/Library/Android/sdk • Platform android-33, build-tools 32.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15A507 • CocoaPods version 1.14.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)

sdksupport-socketmobile commented 12 months ago

Hi @nneuberger1, thanks for reaching out! Your syntax seems correct. I am guessing the issue is related to your new flutter version conflicting somehow with our version of freezed. I found a similar issue with another package and basically the issue appears to be with the fact that google_fonts uses a caret in the version number.

By including the caret in their version number, it basically means it will update to the latest minor version depending on flutter version. So in their code they have google_fonts: ^2.3.1, which means that their project will theoretically use up to version 2.9.9 depending on other dependencies. The issue was essentially resolved by removing the caret.

I am curious if the same thing could help in this case since we use freezed: ^2.3.2. We don't have a release scheduled yet but we will keep this in mind in the near future. In the meantime can you try declaring freezed: 2.3.2 sans carrot in your project, clean caches and do a fresh install? I think that should override out ^2.3.2 declaration.

Also maybe reference freezed_annotation: 2.2.0 in your pubspec.yaml (sans carrot).

This will be greatly informative to us and could show us whether or not we should include it in the next release or if it is another issue entirely.

nneuberger1 commented 11 months ago

Sounds awesome. I'll report back on how things work. I did see that issue out there, but quickly ruled it out as a false positive issue for the fix. Thank you so much for your response! It's really appreciated!

nneuberger1 commented 11 months ago

Here's some more troubleshooting steps. No joy yet. But thank you again for assistance.

I don't have google_fonts as a dependency in my pubspec.xml or pubspec.lock. So that's likely a false positive issue with google fonts and not related or indirectly exposed with their library having the same issues as yours.

freezed_annotation 2.2.0 (from direct dependency to transitive dependency) (2.4.1 available)


I tried: freezed_annotation: 2.4.1

But resulted in the following during builds:


I tried: freezed_annotation: 2.3.2

But resulted in: Because track_stacks depends on freezed_annotation 2.3.2 which doesn't match any versions, version solving failed.

You can try the following suggestion to make the pubspec resolve:


I tried: freezed_annotation: ^2.4.1

But resulted in:

Could not build the precompiled application for the device. Error (Xcode): ../../../../.pub-cache/hosted/pub.dev/capturesdk_flutter-1.4.17/lib/classes/app_info.freezed.dart:25:12: Error: No named parameter with the name 'includeToJson'.


Trying: freezed: 2.3.2 without freezed_annoation referenced in pubspec.yaml

Pulled it in fine:

Failed build:

Could not build the precompiled application for the device. Error (Xcode): ../../../../.pub-cache/hosted/pub.dev/capturesdk_flutter-1.4.17/lib/classes/app_info.freezed.dart:25:12: Error: No named parameter with the name 'includeToJson'.


Trying with: freezed_annotation: 2.4.1 freezed: 2.3.2

Put get worked fine.

Failed build:

Could not build the precompiled application for the device. Error (Xcode): ../../../../.pub-cache/hosted/pub.dev/capturesdk_flutter-1.4.17/lib/classes/app_info.freezed.dart:25:12: Error: No named parameter with the name 'includeToJson'.


Also when I run: dart put deps

I only see the capturesdk_flutter referencing freezed libraries.

├── capturesdk_flutter 1.4.17 │ ├── json_annotation 4.7.0 │ │ └── meta... │ ├── web_socket_channel 2.4.0 │ │ ├── async... │ │ ├── crypto... │ │ └── stream_channel... │ ├── flutter... │ ├── freezed_annotation... │ └── http...

Thanks again for the help. This isn't too urgent yet for me. I'm doing a POC with your hardware, but it would be nice to get a resolution in a couple months if possible. I'll try a few other things, but maybe the capturesdk_flutter might need to be re-compiled since it's using conflicting libraries with freezed now and the new sdk's?

doubleo2 commented 11 months ago

Can you try the following?

freezed: 2.3.2
freezed_annotation: 2.2.0

It looks like freezed_annotation made a breaking change between 2.2.0 and 2.4.1 so you need to pin the 2.2.0 version. In theory, you can use any version of freezed less than 2.4.1 but 2.3.2 is a good version to start with since that's what was used to generate app_info.freezed.dart

nneuberger1 commented 11 months ago

@doubleo2 that didn't work either. I did a flutter clean and verified using dart pub deps that I included those. It still results in the same failure unfortunately.


Could not build the precompiled application for the device. Error (Xcode): ../../../../.pub-cache/hosted/pub.dev/capturesdk_flutter-1.4.17/lib/classes/app_info.freezed.dart:25:12: Error: No named parameter with the name 'includeToJson'.

Is there an active branch that's dev only right now and not released that I can try? Or perhaps wait till a full release with the new libraries and the regenerated class.

mehedidew commented 11 months ago

Did anyone find any workaround?

nneuberger1 commented 11 months ago

@mehedidew not yet. But would love to get a workaround. If the dev team comes back with a pushed side branch I might be able to link it up to my project. Not sure how easy that is because I don't know much about pulling in dependencies like that because the 'hosted/pub.dev/' version might need to be pushed to public repos. I know you can link other projects manually via pubspec. If they come back with that option and a side branch, I might be able to get it working and submit a PR for this project.

nneuberger1 commented 11 months ago

There is an 'example' folder so I might be able to just pull this project down and get things to compile. I think it's still a latest sdk / api changes that force a change on that app_info.freezed.dart generated version.

sdksupport-socketmobile commented 10 months ago

Hi @nneuberger1. Did you have any luck using the example project? If not, did you have any new errors/stack traces?

sdksupport-socketmobile commented 10 months ago

Closing the issue due to inactivity. If this issue still persists please let us know and we can reopen it and assess further.

nneuberger1 commented 10 months ago

No I haven't had time to get back to this issue. I haven't resolved it yet. When I do, I'll report things on this thread and include more information on my status.

sdksupport-socketmobile commented 10 months ago

@nneuberger1 ok thanks. Keep us posted!

mehedidew commented 10 months ago

I found a workaround and built a module using this package. you just have to delete all lock files and try again. Also if you follow the instruction, you'll get a dataType error for event.guid and event.name . Just try calling them using map, as theres no getter function for guid and name in the captureSDK class. Hope this helps