pjproject
pjproject copied to clipboard
Add MAUI example app to csharp samples
This covers #4077 I've created the sample application for both iOS & Android platforms, and some modifications on makefile to generate c# PINVOKE classes to the right project as well
I am stuck with these error when trying to build the app:
/usr/local/share/dotnet/sdk/8.0.403/Microsoft.Common.CurrentVersion.targets(2303,5): error MSB4803: The task "ResolveNativeReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See https://aka.ms/msbuild/MSB4803 for further details. [/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/pjsua2maui.csproj::TargetFramework=net8.0-android]
/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/Platforms/iOS/CallPageHandler.cs(4,40): error CS0234: The type or namespace name 'Compatibility' does not exist in the namespace 'Microsoft.Maui.Controls.Handlers' (are you missing an assembly reference?) [/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/pjsua2maui.csproj::TargetFramework=net8.0-ios]
/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/Platforms/iOS/AppDelegate.cs(6,28): error CS0246: The type or namespace name 'MauiUIApplicationDelegate' could not be found (are you missing a using directive or an assembly reference?) [/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/pjsua2maui.csproj::TargetFramework=net8.0-ios]
/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/Platforms/iOS/CallPageHandler.cs(16,33): error CS0246: The type or namespace name 'VisualElementRenderer<>' could not be found (are you missing a using directive or an assembly reference?) [/pjsip/test/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/pjsua2maui.csproj::TargetFramework=net8.0-ios]
Hello Which version of dotnet you`re using Please post the dotnet setup details
Hi again I'll try to create a global.json to configure the .ned sdk version as the same i've used
Hello @trengginas I've reproduced this when i'm used the global on a mac. And i've done the android sample on windows, which uses the ResolveNativeReference MSBuild Task for resolve the android libs. Try use windows while i'm working on a new android sample
I'm using a Mac since it's not possible to build the iOS sample app on Windows.
To "build on windows" you can use the ssh connection of visual studio to debug and run the iOS app on emulator inside Windows Environment. But if is not possible use a windows pc, try to build one target only (e.g Android only or iOS only).
I also tried this on Mac and encountered the same problem as Riza.
I downloaded the latest VS Code and followed the instruction here: https://learn.microsoft.com/en-us/dotnet/maui/get-started/installation?view=net-maui-9.0&tabs=visual-studio-code
Would you be able to make this work on Mac? Also, please provide us step by step detail (sorry, we are not familiar at all with MAUI project), something similar to https://github.com/pjsip/pjproject/pull/3584.
@sauwming, for sure, i'll work on that today
Thanks, it would be better if the sample apps can work on real devices, instead of simulators. If I tried following Readme.md, I would encounter the following error:
building for iOS Simulator, but linking in object file built for iOS
The steps for real devices are similar, but I'll improve the readme this week
@sauwming I figure it out. The project has a conditional compilation in order to split platforme codes and resources And the inclusion of arm64 library is included in x86_64, causing the bad linking I'll updathe the pr with a including conditional check on arm64 lib
Hi fowks Im working on desktop maui samples, so i maked this as draft It works on windows, but it still need the native platform controls implementation for video win
I still haven't managed to make it work on a real device.
On iOS, it will fail due to an extra opening parenthesis here:
<ItemGroup Condition="(($(RuntimeIdentifier.StartsWith('iossimulator-arm64')))">
But even after I fixed it, it still failed with "undefined references" errors.
that's is wird... the arch on condition is for simulators running on M1/M2 macs the undefined references is about linking could you please post me a build with diag in order to see whats going on with linking?
I finally managed to make it work. I have to specify the RuntimeIdentifier, otherwise it will link with simulator.
dotnet publish -c Debug -f net9.0-ios -p:RuntimeIdentifier=ios-arm64
The result is an .ipa (iOS app package) in pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/bin/Debug/net9.0-ios/ios-arm64/publish/pjsua2maui.ipa, which I can then deploy to the device using Xcode. Not sure if there is an easier way to do this.
The app can run on iOS device. On Android, however, it crashes immediately, as soon as it displays the blue ".NET" logo.
There doesn't seem to be any wrong indications during the build process nor in the Logcat:
dotnet build -t:Run -c Debug -f net9.0-android -v:diag
/usr/local/share/dotnet/sdk/9.0.100/MSBuild.dll -nologo -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/9.0.100/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/9.0.100/dotnet.dll -maxcpucount -property:Configuration=Debug -target:Restore -tlp:default=auto -tlp:verbosity=quiet -verbosity:m -verbosity:diag ./pjsua2maui.sln
/usr/local/share/dotnet/sdk/9.0.100/MSBuild.dll -nologo -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/9.0.100/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/9.0.100/dotnet.dll -maxcpucount -property:TargetFramework=net9.0-android -property:Configuration=Debug -t:Run -tlp:default=auto -verbosity:m -verbosity:diag ./pjsua2maui.sln
pjsua2maui net9.0-android succeeded with 4 warning(s) (87.8s) → pjsua2maui/bin/Debug/net9.0-android/pjsua2maui.dll
/pjproject-maui-android/pjsip-apps/src/swig/csharp/pjsua2maui/pjsua2maui/obj/Debug/net9.0-android/generated/src/Org.Pjsip.PjCamera.cs(20,60): warning CS0618: 'Camera' is obsolete: 'This class is obsoleted in this android platform'
[3 more warnings similar as above]
Build succeeded with 4 warning(s) in 88.2s
Logcat:
12-05 14:06:02.687 1648 17182 W ActivityManager: crash : com.teluu.pjsua2maui,10302
12-05 14:06:02.687 1648 7105 W ActivityTaskManager: Force finishing activity com.teluu.pjsua2maui/crc649fb2e8f84f92675e.MainActivity
When i wrote the sample, i used the .NET 8.0 and it runs fine on android. However, i've upgraded to .NET 9.0 and didn't tested it.
I've debuging the android app on VS using windows, and it shows the crash when the app set's the camera manager by invoking the Java code injected on the app., but it seems that the java code does not being injected to app when putting the files on project app and flagging it as <AndroidJavaSource>SomeFile.java</AndroidJavaSource> .
I'm currently writing a softphone for a company, and faced this issue. My workaround was create a Class Library Project, and produce a library. This way the file is injected to final binary, and the app can handle the PjCamera2 methods loading for set the CameraManager.
I don't know if there is a issue with .NET 9.0, but i can provide a new solution, where the app consumes the wrapper classes and native libraries from a .net maui library project, or even a local nuget package.
Hi folks Sorry by the late answer I've update the version of dotnet sdk, and build the library and tested the project. It seems that the bug on dotnet that was causing the crash on the app initialization was fixed I've fixed one line of android code where the swig generator dont generate one method, and updated the pr