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

Use .jar files from the .NET runtime pack #7665

Conversation

simonrozsival
Copy link
Member

@simonrozsival simonrozsival commented Jan 5, 2023

Since dotnet/runtime#77386 has been merged, .NET will require a certain class from libSystem.Security.Cryptography.Native.Android.jar that will be located in the runtime pack files.

I'm not sure if this is the best way to pull the .jar from the runtimepack so feedback is welcome.

@@ -1341,6 +1341,12 @@ because xbuild doesn't support framework reference assemblies.
<MakeDir Directories="$(MonoAndroidIntermediateAssemblyDir)" Condition=" !Exists ('$(MonoAndroidIntermediateAssemblyDir)') " />
</Target>

<Target Name="_CollectRuntimePackJarFiles">
<ItemGroup>
<AndroidJavaLibrary Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.jar' " />
Copy link
Member

@jonathanpeppers jonathanpeppers Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the .jar file in all 4 runtime packs? android-arm, android-arm64, android-x86, android-x64?

We'll probably have to deduplicate them somehow. Let's wait to look into this, when the changes in dotnet/runtime flow to us.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, each runtimepack should have a copy of the jar file.

@jonathanpeppers
Copy link
Member

I'm going to merge this into our latest Maestro bump, and I'll takeover from there. Thanks!

@jonathanpeppers jonathanpeppers changed the base branch from main to darc-main-595ff03f-9cbb-4090-9ae1-a03d1d30a8e2 January 26, 2023 18:14
@jonathanpeppers jonathanpeppers marked this pull request as ready for review January 26, 2023 18:14
@jonathanpeppers jonathanpeppers merged commit a197ed0 into dotnet:darc-main-595ff03f-9cbb-4090-9ae1-a03d1d30a8e2 Jan 26, 2023
@simonrozsival
Copy link
Member Author

@jonathanpeppers thanks!

jonathanpeppers added a commit that referenced this pull request Jan 28, 2023
Changes: dotnet/installer@9962c6a...779a644
Changes: dotnet/linker@4b3f78c...c790896
Changes: dotnet/runtime@5da4a9e...ddb6988
Changes: dotnet/emsdk@66b9845...5b46122

Updates:

* Microsoft.Dotnet.Sdk.Internal: from 8.0.100-alpha.1.23063.11 to 8.0.100-alpha.1.23070.23
* Microsoft.NET.ILLink.Tasks: from 8.0.100-1.23055.2 to 8.0.100-1.23067.1
* Microsoft.NETCore.App.Ref: from 8.0.0-alpha.1.23058.2 to 8.0.0-alpha.1.23070.1
* Microsoft.NET.Workload.Emscripten.net7.Manifest-8.0.100: from 8.0.0-alpha.1.22620.1 to 8.0.0-alpha.1.23066.1

~~ Other Changes ~~

* Update `.apkdesc` files for app size changes.

* Use .jar files from the .NET runtime pack (#7665)

Since [dotnet/runtime#77386][0] has been merged, .NET will require
a certain class from  `libSystem.Security.Cryptography.Native.Android.jar`
that will be located in the runtime pack files.

[0]: dotnet/runtime#77386

* Disambiguate `.jar` files from Mono runtime packs.

We were getting the build error:

    error JAVA0000: Caused by: com.android.tools.r8.internal.f: Type net.dot.android.crypto.DotnetProxyTrustManager is defined multiple times

This `.jar` file is contained in each runtime pack (4 architectures)
gives us 4 `.jar` files!

We can pass in these files to the `<ProcessAssemblies/>` MSBuild task.

We also filter them based on `%(NuGetPackageId)`, so that any random
`.jar` file doesn't get added to `@(AndroidJavaLibrary)`.

I renamed the `IsFrameworkAssembly()` method to
`IsFromAKnownRuntimePack()` to make this more clear in the existing
code.

* Update `proguard_xamarin.cfg` for .NET 8.

Apps using `$(AndroidLinkTool)` of r8, now need to preserve:

    -keep class net.dot.android.crypto.DotnetProxyTrustManager { *; <init>(...); }

Otherwise we run into a crash when this type isn't present, such as:

    01-26 23:59:19.855  8684  8684 F DEBUG   :       #2 pc 00000000000191d6  /data/app/Mono.Android.NET_Tests-cpTzt8Q9KwgS-znzkuAdNQ==/split_config.x86_64.apk!libSystem.Security.Cryptography.Native.Android.so (offset 0xe7000) (JNI_OnLoad+31302) (BuildId: 7d9e4013a9dd99810070587ab42956703fef69f9)

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Šimon Rozsíval <simon@rozsival.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants