Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

NullReferenceException in AndroidRidAbiHelper.GetNativeLibraryAbi for rooted paths

已关闭
#13,063 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@AustinAviv 已经在做这个了。

开始于 2026年10月10日。

  • #13064 来自 @AustinAviv —— 未关闭

评估

难度
2/5
预计耗时
1 小时以内
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
csharp

调研方向

The bug is in GetNativeLibraryAbi in src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs, around line 43, where dir.Parent and dir.Name are dereferenced without null checks for rooted paths. Read the method's fallback path that inspects the parent directory for android-<abi>/native layouts. Done means a rooted path such as C:\libfoo.so or /libfoo.so returns null instead of throwing. Pull request #13064 already targets this, so review it before starting.

由索引模型根据 Issue 内容生成。

描述

needs-triage
Android framework version

net10.0-android

Affected platform version

.NET 10 / main branch

Description

AndroidRidAbiHelper.GetNativeLibraryAbi throws an unhandled NullReferenceException when a native library path is located directly under a drive root or filesystem root (such as C:\libfoo.so on Windows or /libfoo.so on Linux).

In AndroidRidAbiHelper.GetNativeLibraryAbi (string lib):

var dir = Directory.GetParent (lib);
...
abi = RuntimeIdentifierToAbi (dir.Parent.Name.ToLowerInvariant ());

When lib is directly at the root, Directory.GetParent(lib) returns the root directory (for example C:\), whose .Parent property is null. When dirName does not match a known ABI name, the method checks the parent directory to detect RIDs like android-arm64/native, but dereferences dir.Parent.Name without checking if dir.Parent is null. Additionally, if lib is a root path directly (like / or C:\), Directory.GetParent(lib) returns null directly, causing dir.Name to throw.

Steps to Reproduce

Call AndroidRidAbiHelper.GetNativeLibraryAbi(@"C:\libfoo.so") or pass a TaskItem whose ItemSpec or Link is a rooted path without an intermediate directory.

AndroidRidAbiHelper.GetNativeLibraryAbi(@"C:\libfoo.so");

Observed result:
Throws System.NullReferenceException: Object reference not set to an instance of an object. at line 43.

Expected result:
Returns null without throwing an exception.

Relevant log output
System.NullReferenceException : Object reference not set to an instance of an object.
   at Microsoft.Android.Build.Tasks.AndroidRidAbiHelper.GetNativeLibraryAbi(String lib) in src/Microsoft.Android.Build.BaseTasks/AndroidRidAbiHelper.cs:line 43
主要语言
C#
星标
2.1k
派生
581
平均合并
2 天 6 分钟
30 天内合并 PR
245

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/android 的其他 Issue

查看 dotnet/android 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。