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

Issues Building Android Release version MAUI #155

Open
Pmr-precure opened this issue Oct 31, 2024 · 9 comments
Open

Issues Building Android Release version MAUI #155

Pmr-precure opened this issue Oct 31, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@Pmr-precure
Copy link

Hi,

We cant build our release version. Here is our config:
image

image
image

Not sure whats going on. If we remove the package then we got no issues. Hope you can help.

@Pmr-precure
Copy link
Author

And of cause if we disable R8 then it runs fine.

@ksidirop-laerdal
Copy link
Collaborator

ksidirop-laerdal commented Nov 4, 2024

We've run some tests based on your feedback:

  • We run a sample MAUI app with the settings you indicated in the .csproj and we could replicate the error you're seeing.

  • Rebuilding the nuget using r8 doesn't seem to solve the issue. Same error occurs when trying to build the application that uses the Android nuget.

        <AndroidDexTool>d8</AndroidDexTool>
        <AndroidLinkTool>r8</AndroidLinkTool>
        <AndroidEnableDesugar>True</AndroidEnableDesugar>
        <AndroidEnableProguard>True</AndroidEnableProguard>
        <AndroidEnableMultiDex>True</AndroidEnableMultiDex>
  • By the looks of it R8 is not inspiring confidence in microsoft just yet for them to make it the default option:

https://github.com/dotnet/android/blob/main/Documentation/guides/D8andR8.md#so-how-do-developers-use-it-what-are-sensible-msbuild-property-defaults

I will look further into this but in the meantime I take it that if you turn off R8 (as you already mentioned) and let the build system fallback to using 'proguard' or whatever then the resulting Android application runs acceptably right? Is there any problem in that regard?

@ksidirop-laerdal ksidirop-laerdal self-assigned this Nov 4, 2024
@ksidirop-laerdal ksidirop-laerdal added bug Something isn't working needmoreinfo labels Nov 4, 2024
@Pmr-precure
Copy link
Author

We've run some tests based on your feedback:

  • We run a sample MAUI app with the settings you indicated in the .csproj and we could replicate the error you're seeing.
  • Rebuilding the nuget using r8 doesn't seem to solve the issue. Same error occurs when trying to build the application that uses the Android nuget.
        <AndroidDexTool>d8</AndroidDexTool>
        <AndroidLinkTool>r8</AndroidLinkTool>
        <AndroidEnableDesugar>True</AndroidEnableDesugar>
        <AndroidEnableProguard>True</AndroidEnableProguard>
        <AndroidEnableMultiDex>True</AndroidEnableMultiDex>
  • By the looks of it R8 is not inspiring confidence in microsoft just yet for them to make it the default option:

https://github.com/dotnet/android/blob/main/Documentation/guides/D8andR8.md#so-how-do-developers-use-it-what-are-sensible-msbuild-property-defaults

I will look further into this but in the meantime I take it that if you turn off R8 (as you already mentioned) and let the build system fallback to using 'proguard' or whatever then the resulting Android application runs acceptably right? Is there any problem in that regard?

Hi,

I managed to build the project with R8 adding this to the proguard.cfg

-keep class com.laerdal.mcumgr.** { *; }
-keepattributes Annotation, Signature, EnclosingMethod, InnerClasses

@ksidirop-laerdal
Copy link
Collaborator

I guess you mean to say that this was added in the proguard.cfg of your application right? (or did you tweak the proguard.cfg of the Laerdal.McuMgr java-lib itself?)

-keep class com.laerdal.mcumgr.** { *; }
-keepattributes Annotation, Signature, EnclosingMethod, InnerClasses

Appreciate the follow up info.

@Pmr-precure
Copy link
Author

I guess you mean to say that this was added in the proguard.cfg of your application right? (or did you tweak the proguard.cfg of the Laerdal.McuMgr java-lib itself?)

-keep class com.laerdal.mcumgr.** { *; }
-keepattributes Annotation, Signature, EnclosingMethod, InnerClasses

Appreciate the follow up info.

No no our application :)

@ksidirop-laerdal
Copy link
Collaborator

Quick headsup: I have this issue on my radar - just very busy during this period. But I will tackle this at some point for sure.

@Pmr-precure
Copy link
Author

Quick headsup: I have this issue on my radar - just very busy during this period. But I will tackle this at some point for sure.

No problem:) as long we modify our proguard.cfg, everything is fine. :)

@Pmr-precure
Copy link
Author

Pmr-precure commented Dec 2, 2024

a little update to this. Using R8 and doing the erase method this is thrown:
java.lang.NoSuchMethodException: com.fasterxml.jackson.databind.SerializationFeature.values

image

An error occurred while erasing firmware: '[AFE.BE.020] Erasure failed 'com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of io.runtime.mcumgr.response.img.McuMgrImageResponse (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information

** Update.
Adding to our proguard.cfg fixed the issue:
-keep class com.fasterxml.jackson.** { *; }
-keep class io.runtime.mcumgr.response.img.McuMgrImageResponse { *; }

@ksidirop-laerdal
Copy link
Collaborator

Noted and much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants