Closed starhound closed 3 years ago
Transferring to Xamarin.Essentials repo. If the issue turns out to be in Android SDK, feel free to send it back!
My apologies, this issue is probably related directly to said repo. Thanks for the support in transferring the issue!
Looking at the stack trace, I see Dialer.OpenDialer
. This is not part of Essentials. We have a PhoneDialer.Open
and the first thing we do is check for empty and null strings. We then throw a ArgumentNullException
.
Are you sure in this specific case you are using Essentials?
Also 3 things..
1.) you need to try/catch it because there may not be a dialer on the device 2.) you need to ensure you initialize xamarin.essentials if you are using xamarin.essentials 3.) you need to ensure you added the query parameters: https://docs.microsoft.com/en-us/xamarin/essentials/phone-dialer?tabs=android#get-started
My apologies, I have a 'Dialer' class in my project which handles getting numbers from an endpoint, here is the Dialer.OpenDialer() function, which is exactly the same function as jamesmontemagno linked.
public static void OpenDialer(string number) { MainActivity main = new MainActivity(); try { PhoneDialer.Open(number); } catch (ArgumentNullException anEx) { main.DisplayFailureNotice(anEx.Message); } catch (FeatureNotSupportedException ex) { main.DisplayFailureNotice(ex.Message); } catch (Exception ex) { main.DisplayFailureNotice(ex.Message); } }
Sorry for the unusual format, the Code markdown looked worse.
When I pass "" to PhoneDialer.Open(), no alert is shown (which is what DisplayFailureNotice() does), the app completely crashes, and the stack trace I've posted in my initial issue is given to me from the VS App center crash analytics.
For reference, my app is running on Moto z4's and some z3's and works great for what we need it to do, I simply noticed this happening during development and figured I'd mention something as I believed it wasn't intended behavior.
Maybe you are missing the queries as James mentioned. This is new I. The latest Android, so that might be why it is failing now.
Android just dies if the permissions are wrong.
The various permissions I use:
I also grab more phone permissions through a plugin but that's unrelated to this function.
My Dialer class works just fine when passed proper number strings, the application has a page with a few buttons that open the dialer with various numbers for employees (think Call HR, Call IT). All buttons utilize the OpenDialer() function, all work as expected when being passed a non-empty string.
My sdk min version is 28, the max being 29.
I can't seem to repro this. I have created a test sample that tries null
, ""
and "123"
. All seem to work for me.
After about half a day of work I've discovered the issue to be in main.DisplayFailureNotice(), not the dialing service.
I apologize for the confusion. Thank you for your time and attention, I wish you all the best.
Closing issue now.
Glad you got it all sorted!
My apologies if the wrong label has been attached. Unsure what category to submit this issue under.
Steps to Reproduce
Expected Behavior
Phone dialer to open with no number specified.
Actual Behavior
Total app crash
Version Information
Microsoft Visual Studio Community 2019 Version 16.8.1 VisualStudio.16.Release/16.8.1+30711.63 Microsoft .NET Framework Version 4.8.03752
Installed Version: Community
Visual C++ 2019 00435-60000-00000-AA162 Microsoft Visual C++ 2019
ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools
ASA Service Provider 1.0
ASP.NET and Web Tools 2019 16.8.550.19892 ASP.NET and Web Tools 2019
ASP.NET Core Razor Language Services 16.1.0.2052803+84e121f1403378489b842e1797df2f3f5a49ac3c Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2019 16.8.550.19892 For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 16.8.550.19892 Azure App Service Tools v3.0.0
Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer.
Azure Data Lake Tools for Visual Studio 2.6.1000.0 Microsoft Azure Data Lake Tools for Visual Studio
Azure Stream Analytics Tools for Visual Studio 2.6.1000.0 Microsoft Azure Stream Analytics Tools for Visual Studio
Bundler & Minifier 2.8.396 Adds support for bundling and minifying JavaScript, CSS and HTML files in any project.
C# Tools 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
CSS Tools 2019 1.1.4 Provides additional features to the CSS editor in Visual Studio.
Editor Enhancements 1.0.30 Provides additional features such as HTML and URL encodings, transformations and sorting of selected text the editor.
Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
GitHub.VisualStudio 2.11.106.19330 A Visual Studio Extension that brings the GitHub Flow into Visual Studio.
IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info
Microsoft Azure HDInsight Azure Node 2.6.1000.0 HDInsight Node under Azure Node
Microsoft Azure Hive Query Language Service 2.6.1000.0 Language service for Hive query
Microsoft Azure Stream Analytics Language Service 2.6.1000.0 Language service for Azure Stream Analytics
Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node
Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1
Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 2.1.113+g422d40002e.RR Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 16.8.43 (00471f8) Support for debugging Mono processes with Visual Studio.
Node.js Tools 1.5.20902.1 Commit Hash:b474efcb6f92db52a8f8e2e6a8cb9648476885cc Adds support for developing and debugging Node.js apps in Visual Studio
NuGet Package Manager 5.8.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info
SQL Server Data Tools 16.0.62010.06180 Microsoft SQL Server Data Tools
Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
ToolWindowHostedEditor 1.0 Hosting json editor into a tool window
TypeScript Tools 16.0.21016.2001 TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 16.8.0-beta.20507.4+da6be68280c89131cdba2045525b80890401defd Microsoft Visual F# Tools
Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Container Tools Extensions 1.0 View, manage, and diagnose containers within Visual Studio.
Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake
Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers
VisualStudio.DeviceLog 1.0 Information about my package
VisualStudio.Mac 1.0 Mac Extension for Visual Studio
Web Essentials 2019 0.5.10 The easiest way to set up Visual Studio for the ultimate web development experience.
Xamarin 16.8.000.255 (d16-8@d002176) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.8.0.507 (remotes/origin/d16-8@e87b24884) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.8.112 (86385a3) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 11.1.0.17 (d16-8/c0e2b8e) Xamarin.Android Reference Assemblies and MSBuild support. Mono: be2226b Java.Interop: xamarin/java.interop/d16-8@79d9533 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc
Xamarin.iOS and Xamarin.Mac SDK 14.4.1.3 (e30c41de3) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
--Please put instructions for Windows, not Mac if more information is requested.
Log File
--Once again, please provide Windows instructions. This stack trace is from the VS App Center.