-
Notifications
You must be signed in to change notification settings - Fork 534
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] redistribute proguard-android.txt
from Android gradle plugin
#9485
Conversation
Removing the line in this PR is fine for main, but it seems like the rules here might be needed: As mentioned here: The Android SDK doesn't seem to redistribute any proguard rules anymore, but they have it in their repo? |
Hmm:
So, we might have to dig up what the Android Gradle plugin does and port the logic to C#? |
We should not merge this PR until better understand the Android Gradle plugin behavior. |
I think I should:
Some links:
|
…m Android gradle plugin Context: https://discord.com/channels/732297728826277939/732297837953679412/1303383272918618163 A customer found their app grew in size when building on Windows versus macOS. The difference being a file that was passed to the `<R8/>` task on Windows, but not on macOS: C:\Users\[username]\AppData\Local\Android\Sdk\tools\proguard\proguard-android.txt `tools` is *ancient*, as any Android SDK should be using `cmdline-tools` now. Let's stop using this file as a default set of proguard rules. But we need to use the *right* set of proguard rules, reading the text of the old one: > This file is no longer maintained and is not used by new (2.2+) > versions of the # Android plugin for Gradle. Instead, the Android > plugin for Gradle generates the # default rules at build time and > stores them in the build directory. I found the source code for the gradle task that generates the new files at: * https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/ProguardFiles.java;l=116 In order to get this file, we can setup an empty gradle project using the Android gradle plugin: plugins { id 'com.android.application' version '8.7.0' } Which, hopefully, dependabot is able to update this version. Then we can run the task: .\gradlew extractProguardFiles This outputs files such as: src\proguard-android\build\intermediates\default_proguard_files\global\proguard-android-optimize.txt-8.7.0 src\proguard-android\build\intermediates\default_proguard_files\global\proguard-android.txt-8.7.0 src\proguard-android\build\intermediates\default_proguard_files\global\proguard-defaults.txt-8.7.0 For now, I simply redistributed the `proguard-android.txt` file, but we could consider making `proguard-android-optimize.txt` useable in the future. I believe the only difference is the `-allowaccessmodification` flag, which users could put in their own proguard rules.
1682328
to
4ee6762
Compare
proguard-android.txt
from Android SDK toolsproguard-android.txt
from Android gradle plugin
I was going to add a TPN, like: using System;
using System.Collections.Generic;
using System.IO;
namespace Xamarin.Android.Prepare;
[TPN]
class android_build_tools_gradle_TPN : ThirdPartyNotice
{
// https://mvnrepository.com/artifact/com.android.tools.build/gradle
static readonly Uri url = new Uri ("https://android.googlesource.com/platform/tools/base");
public override string LicenseFile => CommonLicenses.Apache20Path;
public override string Name => "google/com.android.tools.build/gradle";
public override Uri SourceUrl => url;
public override string LicenseText => String.Empty;
public override bool Include (bool includeExternalDeps, bool includeBuildDeps) => includeExternalDeps;
} When running Then I found we already have an entry for this: android/build-tools/xaprepare/xaprepare/ThirdPartyNotices/Xamarin.Android.Build.Tasks.cs Lines 7 to 16 in 70948d5
So, maybe we are good and no TPN changed needed? |
Should we update the existing TPN URL to? https://android.googlesource.com/platform/tools/base/+/refs/heads/main/sdk-common/NOTICE (explicit branch name of |
…m Android gradle plugin (#9485) Context: https://discord.com/channels/732297728826277939/732297837953679412/1303383272918618163 A customer found their app grew in size when building on Windows versus macOS. The difference being a file that was passed to the `<R8/>` task on Windows, but not on macOS: C:\Users\[username]\AppData\Local\Android\Sdk\tools\proguard\proguard-android.txt `tools` is *ancient*, as any Android SDK should be using `cmdline-tools` now. Let's stop using this file as a default set of proguard rules. But we need to use the *right* set of proguard rules, reading the text of the old one: > This file is no longer maintained and is not used by new (2.2+) > versions of the # Android plugin for Gradle. Instead, the Android > plugin for Gradle generates the # default rules at build time and > stores them in the build directory. I found the source code for the gradle task that generates the new files at: * https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/ProguardFiles.java;l=116 In order to get this file, we can setup an empty gradle project using the Android gradle plugin: plugins { id 'com.android.application' version '8.7.0' } Which, hopefully, dependabot is able to update this version. Then we can run the task: .\gradlew extractProguardFiles This outputs files such as: src\proguard-android\build\intermediates\default_proguard_files\global\proguard-android-optimize.txt-8.7.0 src\proguard-android\build\intermediates\default_proguard_files\global\proguard-android.txt-8.7.0 src\proguard-android\build\intermediates\default_proguard_files\global\proguard-defaults.txt-8.7.0 For now, I simply redistributed the `proguard-android.txt` file, but we could consider making `proguard-android-optimize.txt` useable in the future. I believe the only difference is the `-allowaccessmodification` flag, which users could put in their own proguard rules. Also, updated TPN url for: https://android.googlesource.com/platform/tools/base/+/refs/heads/main/sdk-common/NOTICE
Context: https://discord.com/channels/732297728826277939/732297837953679412/1303383272918618163
A customer found their app grew in size when building on Windows
versus macOS.
The difference being a file that was passed to the
<R8/>
task onWindows, but not on macOS:
tools
is ancient, as any Android SDK should be usingcmdline-tools
now.Let's stop using this file as a default set of proguard rules.
But we need to use the right set of proguard rules, reading
the text of the old one:
I found the source code for the gradle task that generates the new
files at:
In order to get this file, we can setup an empty gradle project
using the Android gradle plugin:
Which, hopefully, dependabot is able to update this version.
Then we can run the task:
This outputs files such as:
For now, I simply redistributed the
proguard-android.txt
file, butwe could consider making
proguard-android-optimize.txt
useable inthe future. I believe the only difference is the
-allowaccessmodification
flag, which users could put in their ownproguard rules.