Skip to content

Review Android AssemblyReader #3761

Closed
2 of 2 issues completed
Closed

Description

@bruno-garcia

Came up on Discord:

Our current version of Android AssemblyReader was taken from this sha:

Upstream, as the history shows:

A change was done to it since:

I didn't look into it but might be related to making assemblies RID specific, changing the internal layout of the apk:

Activity

  1. added this to the 5.0.0 milestone on Nov 17, 2024
  2. bruno-garcia commented on Nov 17, 2024

    @bruno-garcia
    MemberAuthor

    @jamescrosswell @bricefriha one way to test if things are working, is getting a Release built Android app built on .NET 9, and see if we still get all C# line numbers in exceptions and crashes

  3. jamescrosswell commented on Mar 5, 2025

    @jamescrosswell
    Collaborator

    @jamescrosswell @bricefriha one way to test if things are working, is getting a Release built Android app built on .NET 9, and see if we still get all C# line numbers in exceptions and crashes

    Argh... this obviously slipped through the cracks.

    .NET 9 does introduced a new AssemblyStore format for APK files. Reading the new format is demonstrated in assembly-store-reader-mk2 (which is a newer version of the store reader to the one we vendored in).

    The relvant commits appear to be:

    Unfortunately the code for assembly-store-reader-mk2 isn't yet complete and the functionality to read v1 store formats hasn't yet been implemented. As such, we're going to have to:

    1. Vendor in the code to read v2 stores from assembly-store-reader-mk2
    2. Find some way to determine whether the store is a v1 or v2 store and instantiate the appropriate reader (we already have an AndroidAssemblyReaderFactory that creates either a directory reader or a store reader)... hopefully we can extend this so it returns v1 or v2 as appropriate

    Additionally, the current code we've got gets the apk path as so:

    var apkPath = Application.Context.ApplicationInfo?.SourceDir;

    I'm not sure if that actually works in .NET 8 (needs to be tested). In .NET 9 at least, this returns /somepath/base.apk and, whilst that apk does exist in net9.0, it doesn't contain any of the .NET assemblies that we need to load. Instead, these appear to be in /somepath/split_config.[arch].apk (e.g. /somepath/split_config.arm64_v8a.apk on an arm64 v8a device).

    It is possible to get a list of all the source dirs via Application.Context.ApplicationInfo?.SplitSourceDirs so we'll have to identify the appropriate path in that array based on the current architecture and then open that file in our new v2 store reader.

    I tested this on a Release build of the Sentry.Samples.Maui application, using assembly-store-reader-mk2 tool from the dotnet/android repo and it works. So now all we have to do is vendor in that code as a new reader and find a way to instanciate the appropriate reader.

  4. pinned this issue on Mar 6, 2025
  5. unpinned this issue on May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions