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

Archiving apk using .net 7.0+ for android includes wrong platforms #8165

Closed
jfversluis opened this issue Jul 4, 2023 · 14 comments
Closed

Archiving apk using .net 7.0+ for android includes wrong platforms #8165

jfversluis opened this issue Jul 4, 2023 · 14 comments
Labels
need-attention A xamarin-android contributor needs to review needs-triage Issues that need to be assigned. vs-sync For internal use only; creates a VSTS "mirror" issue.

Comments

@jfversluis
Copy link
Member


Issue moved from dotnet/maui#15971


From @mosammo on Monday, July 3, 2023 9:04:33 AM

Description

[severity:I’m unable to use this version]
Archiving apk using .net 7.0 for android with “Target platform” “ARM64” produces large apk that includes assemblies of other platforms “X86” and “x64” which increases apk size considerably.

Expected behavior is to only include assemblies of the selected target platform. For example if we select “ARM32” it should not include other platforms like “ARM64”, “X86” and “x64”.

Latest visual studio 2022 17.6.2

Steps to Reproduce

simple steps:

  1. Create a maui project.
  2. Right click the project to select the properties change Target platform to “ARM64” under Build->General
  3. Build the project then archive apk.

To check it simply rename the apk as .zip file then open it and check folders “assemblies” and “bin” inside the apk. (please check attached screenshots)

Link to public reproduction project repository

https://github.com/mosammo/DotNetIssues

Version with bug

7.0.49

Last version that worked well

6.0

Affected platforms

Android

Affected platform versions

.net 7 for android

Did you find any workaround?

no

Relevant log output

No response

@jfversluis
Copy link
Member Author


Issue moved from dotnet/maui#15971


From @mosammo on Monday, July 3, 2023 9:07:22 AM

Example apk for platform "ARM64" including unselected platforms assemblies
large apk size due to including wrong platforms

@jfversluis

This comment was marked as off-topic.

@jfversluis

This comment was marked as off-topic.

@jfversluis

This comment was marked as off-topic.

@jonpryor
Copy link
Member

jonpryor commented Jul 5, 2023

@mosammo: When you say "Archiving apk", are you referring to the Archive Manager within Visual Studio Tools > Archive Manager…?

@jonpryor jonpryor added the need-info Issues that need more information from the author. label Jul 5, 2023
@ghost
Copy link

ghost commented Jul 5, 2023

Hi @jfversluis. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@mosammo
Copy link

mosammo commented Jul 6, 2023

Archiving apk can be done in multiple ways:

  • simplest option: right clicking the android project in "solution explorer" then click "Archive..."
  • or use "Build" > "Archive..."
    After the apk is created simply rename the apk as .zip file then open it and check folders “assemblies” and “lib” inside the apk.
    image
    (please check above screenshots)

@ghost ghost added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Jul 6, 2023
@jonpryor jonpryor added the vs-sync For internal use only; creates a VSTS "mirror" issue. label Jul 8, 2023
@jpobst
Copy link
Contributor

jpobst commented Jul 10, 2023

This option in VS seems to set:

<PlatformTarget>ARM64</PlatformTarget>

I think the first question is: is this the correct thing to set? I suspect we should be setting something like $(AndroidSupportedAbis) instead. @jonathanpeppers?

If so, then I think we need to give this to the UI team to set the correct property. I don't know how much they can change the "General" property pages in VS instead of the Android specific ones.

@jonathanpeppers
Copy link
Member

My Project Options page is broken in VS right now (they know about it):

image

So, I can't get a screenshot...

RuntimeIdentifiers is what you want to set, but we should double-check the project options page has the option to adjust that value.

So, if you only want 64-bit, you could do:

<RuntimeIdentifiers>android-arm64;android-x64</RuntimeIdentifiers>

@jpobst
Copy link
Contributor

jpobst commented Jul 10, 2023

Yeah, I don't see anything else that looks like runtime identifiers in the property pages.

@mosammo
Copy link

mosammo commented Jul 10, 2023

Thank you guys, turns out it is indeed just a visual studio UI issue and setting "RuntimeIdentifiers" manually fixes it
#8168 (comment)

@dellis1972
Copy link
Contributor

The PlatformTarget is not the right property to change to these. You should probably leave that as AnyCPU for Android based projects (and probably all platforms to be honest).

RuntimeIdentifiers is the thing you can use to specify which android abi's you want to target.

@mosammo
Copy link

mosammo commented Jul 12, 2023

The PlatformTarget is not the right property to change to these. You should probably leave that as AnyCPU for Android based projects (and probably all platforms to be honest).

RuntimeIdentifiers is the thing you can use to specify which android abi's you want to target.

Yes, it's a visual studio UI bug in project settings: the displayed property "Platform target" has no actual use at all, while the needed property "Runtime Identifiers" is missing from the UI

@jpobst
Copy link
Contributor

jpobst commented Aug 10, 2023

This issue likely occurs in the Visual Studio integration, which is owned by a different team who does not use GitHub for issue tracking.

Please use the tools available inside of VS to report this issue. This allows the issue to be routed to the correct team.

Thanks!

@jpobst jpobst closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need-attention A xamarin-android contributor needs to review needs-triage Issues that need to be assigned. vs-sync For internal use only; creates a VSTS "mirror" issue.
Projects
None yet
Development

No branches or pull requests

6 participants