Skip to content
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

in maui, android, getting nullreference exception when creating ablyRest and AblyRealtime in Release #1241

Closed
kjetil-gdm opened this issue Jun 19, 2023 · 6 comments
Assignees

Comments

@kjetil-gdm
Copy link

kjetil-gdm commented Jun 19, 2023

Code:
var options = new ClientOptions();
options.Key = "[apikey with Channel Metadata, History, Presence, Publish, Statistics, Subscribe]";
options.AutomaticNetworkStateMonitoring = false;
AblyRest ably_client_rest = new AblyRest(options);

This works in debug mode (debugging on actual Android device).
When built for Release (and testing on actual device) it causes the following exception:
"Object reference not st to an instance of an object".
Tracke: at IO.Ably.IoC.get_MobileDevice())
at IO.Ably.AblyRest...ctor(ClientOptions)
...
Creating AblyRealtime causes the same issue.

ably.io version 1.2.11,
target .net runtime: 7.0
maui

Am I missing a permission something, seeing how this works in debug but not release?

@sync-by-unito
Copy link

sync-by-unito bot commented Jun 19, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3656

@sacOO7
Copy link
Collaborator

sacOO7 commented Jun 19, 2023

Hey, ideally it should work if it's working in debug mode. Can you post the full code snippet and full error log?
If it's a small app, it would be great if you can upload it as a test repo, that would be really easy for us to recreate the bug.

@sacOO7
Copy link
Collaborator

sacOO7 commented Jun 19, 2023

For more information, you can take a look at this issue #1205

@sacOO7
Copy link
Collaborator

sacOO7 commented Jun 19, 2023

I had a hunch but now it seems it might be clear why app doesn't work in release mode. It seems some level of assembly stripping must be happening in release mode. You can check this thread -> #764 (comment).

You should disable assembly trimming for IO.Ably.dll using thse options -> https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0

@kjetil-gdm Let me know if this configuration works for you.

@kjetil-gdm
Copy link
Author

Thanks sac007,
resolved the issue by adding the following in the .csproj file:

<ItemGroup>
  <TrimmerRootAssembly Include="IO.Ably" />
</ItemGroup>

@sacOO7
Copy link
Collaborator

sacOO7 commented Jun 20, 2023

@kjetil-gdm Great! Feel free to raise more issues if you face any problems in the future : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants