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

[Xamarin.Android.Build.Tasks] Add support for Proguard mapping.txt file #5304

Merged
merged 1 commit into from
Nov 19, 2020

Conversation

dellis1972
Copy link
Contributor

Fixes #5186

When uploading a package to the Google Play Store users are seeing
the following warning.

This App Bundle contains Java/Kotlin code, which might be obfuscated.

To fix this users need to provide a mapping.txt file which contains
the Java class mappings from their plain versions to the ones which
are obfuscated. By default we do not obfuscate the java code but the
warning still shows.

To fix this issue we have a new property $(AndroidProguardMappingFile)
which defaults to $(OutputPath)mapping.txt. This file will be produced
as part of the build process. In order for this mapping file to be
generated the following lines needed to be added to the proguard_xamarin.cfg
file.

-keepattributes SourceFile
-keepattributes LineNumberTable

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

Should we update one test to check mapping.txt exists?

…file.

Fixes dotnet#5186

When uploading a package to the Google Play Store users are seeing
the following warning.

    This App Bundle contains Java/Kotlin code, which might be obfuscated.

To fix this users need to provide a `mapping.txt` file which contains
the Java class mappings from their plain versions to the ones which
are obfuscated. By default we do not obfuscate the java code but the
warning still shows.

To fix this issue we have a new property `$(AndroidProguardMappingFile)`
which defaults to `$(OutputPath)mapping.txt`. This file will be produced
as part of the build process. In order for this mapping file to be
generated the following lines needed to be added to the `proguard_xamarin.cfg`
file.

    -keepattributes SourceFile
    -keepattributes LineNumberTable
@jonathanpeppers
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

I restarted CI, looks good to me otherwise.

@jonpryor jonpryor merged commit 2dab2bc into dotnet:master Nov 19, 2020
@dellis1972 dellis1972 deleted the Issue5186 branch November 19, 2020 09:39
pjcollins added a commit to pjcollins/android that referenced this pull request Nov 19, 2020
Context: dotnet#5304

The Proguard mapping.txt PR was not quite ready for prime time and has
seemingly caused some new proguard test failures and an .apk size
regression in our Xamarin.Forms baseline.  Let's disable this by default
for now until we can fix these issues.
jonathanpeppers pushed a commit that referenced this pull request Nov 19, 2020
Context: #5304

The Proguard mapping.txt PR was not quite ready for prime time and has
seemingly caused some new proguard test failures and an .apk size
regression in our Xamarin.Forms baseline.  Let's disable this by default
for now until we can fix these issues.
@brendanzagaeski brendanzagaeski added bug Component does not function as intended. enhancement Proposed change to current functionality. labels Nov 20, 2020
@EmilAlipiev
Copy link

thats is awesome. is it already in any release we can test. By the way, it is said that Xamarin.Android r8 doesnt do obfuscation, is it correct?

@dellis1972
Copy link
Contributor Author

@EmilAlipiev it should be in d16-9 Preview 2 (I think). Generally we turn off r8 obfuscation because it stops our C#->Java intro layer working see https://github.com/xamarin/xamarin-android/blob/master/src/Xamarin.Android.Build.Tasks/Resources/proguard_xamarin.cfg#L3

@EmilAlipiev
Copy link

This seems to be working in the latest releases. when i locally build, i can see that mapping.txt file is generated but in the AzureDevops i am not able to see the file under the artifacts. Do i have to something special in my Yaml file?

@dellis1972
Copy link
Contributor Author

@EmilAlipiev It takes a while for the latest release to get on to DevOps (assuming you are using the system installed XA on DevOps). As they have to update the image, tests it etc.

Perhaps it might be better to use a tool like boots to install the specific version you want?

@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Component does not function as intended. enhancement Proposed change to current functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Warning in Google Console when publishing an app from Visual Studio
5 participants