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

GetAllNetworkInterfaces fails on Android #35836

Closed
pjcollins opened this issue May 5, 2020 · 9 comments
Closed

GetAllNetworkInterfaces fails on Android #35836

pjcollins opened this issue May 5, 2020 · 9 comments

Comments

@pjcollins
Copy link
Member

System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces ()
is crashing on Android when using our very early Xamarin SDK preview bits:

05-05 10:49:44.065 31222 31222 E AndroidRuntime: Process: UnnamedProject.UnnamedProject, PID: 31222
05-05 10:49:44.065 31222 31222 E AndroidRuntime: android.runtime.JavaProxyThrowable: System.Net.NetworkInformation.NetworkInformationException (2): No such file or directory
05-05 10:49:44.065 31222 31222 E AndroidRuntime:    at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces()
05-05 10:49:44.065 31222 31222 E AndroidRuntime:    at System.Net.NetworkInformation.NetworkInterfacePal.GetAllNetworkInterfaces()
05-05 10:49:44.065 31222 31222 E AndroidRuntime:    at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
05-05 10:49:44.065 31222 31222 E AndroidRuntime:    at UnnamedProject.MainActivity.<>c.<OnCreate>b__1_0(Object <p0>, EventArgs <p1>)

Steps to Reproduce

  1. Ensure you have a recent .NET 5 preview build installed.
  2. Download the repro here: BuildXASdkProjectFalse.zip
  3. Run the sample and click the button.
dotnet build /t:Run ~/Downloads/BuildXASdkProjectFalse/UnnamedProject.csproj /v:n

This project is configured to run on an x86 emulator by default. If you want to test on a physical device the RuntimeIdentifier element in the .csproj file will need to be updated.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels May 5, 2020
@ghost
Copy link

ghost commented May 5, 2020

Tagging subscribers to this area: @dotnet/ncl
Notify danmosemsft if you want to be subscribed.

@EgorBo EgorBo self-assigned this May 5, 2020
@wfurt
Copy link
Member

wfurt commented May 5, 2020

Is the /proc available like normal Linux? The NetworkInfo code heavily depends on it and we have seen similar cases on the past with WSL when some entries are missing or incomplete.

Also this looks like unhandled exception more than crash.

@marek-safar marek-safar added this to the 6.0.0 milestone Jun 24, 2020
@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label Jun 24, 2020
@pjcollins pjcollins changed the title GetAllNetworkInterfaces crashes on Android using early .NET 5 previews [One .NET] GetAllNetworkInterfaces fails on Android Nov 5, 2020
@marek-safar marek-safar changed the title [One .NET] GetAllNetworkInterfaces fails on Android GetAllNetworkInterfaces fails on Android Nov 5, 2020
@steveisok
Copy link
Member

This looks like something we'll need to resolve similar to our HttpHandler integration. In mono, we were reaching into Xamarin libraries we won't have access to.

jonpryor pushed a commit to dotnet/android that referenced this issue Nov 16, 2020
A new version of Mono.Android-Tests has been added to run against the
.NET 6 SDK:

   * `tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Mono.Android.NET-Tests.csproj`

To support this, new .NET `.csproj` files have been added alongside
all of the existing legacy Xamarin.Android unit test library projects.
These projects target `net5.0-android` and build against our
.NET 6 SDK (6f761ea):

  * `src/Mono.Android/Test/Java.Interop-Tests/Java.Interop-Tests.NET.csproj`
  * `src/Mono.Android/Test/Mono.Android-Test.Library/Mono.Android-Test.Library.NET.csproj`
  * `src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.NET.csproj`
  * `tests/TestRunner.Core/TestRunner.Core.NET.csproj`
  * `tests/TestRunner.NUnit/TestRunner.NUnit.NET.csproj`

The `_CreateAar` target was being skipped for the new
`Java.Interop-Tests.NET` project, as it had no inputs.  As a result,
the `Mono.Android-Test-classes.jar` file required by these tests was
not being included in the application project.  To fix this, I've added
`@(AndroidJavaLibrary)` to `@(_CreateAarInputs)` so that these items
will also be considered as inputs for this target/task.

All tests which have been ignored are tied back to one of the following issues:

  * Mono.Data.Sqlite is not supported.
  * Secondary AppDomains are not supported.
  * Missing crypto/networking support in dotnet/runtime.
  * dotnet/runtime#35836
  * dotnet/runtime#44358
  * #5265
  * #5275
@EgorBo EgorBo removed their assignment Feb 10, 2021
@pjcollins
Copy link
Member Author

@steveisok To provide a quick update here, this issue is still present in 6.0.0-preview.4.21177.4.

@steveisok
Copy link
Member

Related to #51303

@wfurt
Copy link
Member

wfurt commented Apr 20, 2021

can you check @steveisok what file it is trying to access and if we are hitting the "getifaddrs" path or the legacy /proc implementation?
I'm wondering if we are hitting the second because some header or detection issue during configuration.

@wfurt
Copy link
Member

wfurt commented Apr 20, 2021

https://github.com/morristech/android-ifaddrs is 8 years old and I'm wondering if anything changed since then. Netlink now works (somehow) with .NET so we could do something similar if needed. That would possibly allow some other NetworkInfo functions as well if needed.

@wfurt
Copy link
Member

wfurt commented Apr 20, 2021

https://android.googlesource.com/platform/bionic/+/master/libc/include/ifaddrs.h
makes comment about API level 24. Can we use it and throw PNSP on older versions?

@marek-safar
Copy link
Contributor

Closing this in favour of #51303

@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants