-
Notifications
You must be signed in to change notification settings - Fork 564
Add apkdiff tool #4221
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
Add apkdiff tool #4221
Conversation
Context: https://github.com/xamarin/xamarin-android/projects/14 Context: dotnet#4191 And use it to produce `.apkdesc` files. These files will be later used instead of the size reference files we have now. They contain more detailed size information and also improve the readability compared to the `.csv` files. The `.apkdesc` files look like: { "Comment": "HEAD/master: cdc04224edcb876ae6607693ea4011fee8c76893", "PackageSize": 75817581, "Entries": { "AndroidManifest.xml": { "Size": 5428 }, "res/drawable/android_button.xml": { "Size": 588 }, ... }
Instead of packages.config
| @@ -0,0 +1,60 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I think about it, should all new projects be SDK style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Do we have a migration tool available on Mac or do I need to do it by hand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@radekdoulik I found they are so short you can type them now:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
</Project>It has a bunch of conventions based on the csproj file name. You can also delete Properties\AssemblyInfo.cs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I did similar thing here radekdoulik/apkdiff@8608ae3
I guess I will need to modify the OutputPath in addition to that in XA.
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
"Silly" question: do we really want |
The choice is motivated mostly by better readability. |
build-tools/scripts/TestApks.targets
Outdated
| </PropertyGroup> | ||
| <Exec | ||
| Condition=" Exists('$(ApkDiffPath)') " | ||
| Command=""$(ApkDiffPath)" -v -c "HEAD/`git branch --show-current`: `git rev-parse HEAD`" -s "%(_AllArchives.Identity)";mv "%(_AllArchives.RelativeDir)\%(_AllArchives.Filename).apkdesc" "%(_AllArchives.RelativeDir)\%(_AllArchives.Filename)-$(Configuration)-$(TestsFlavor).apkdesc"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that -$(TestsFlavor) can instead be $(TestsFlavor).
Right now the xa-test-results-10.2.99.215_739a18a-Darwin-Release.zip file contains filenames such as:
% find . -iname \*.apkd\*
./Xamarin.Android.EmbeddedDSO_Test-Signed-Release-.apkdesc
./Mono.Android_Tests-Signed-Release--Profiled-Aot.apkdesc
./Xamarin.Forms_Performance_Integration-Signed-Release-.apkdesc
./Xamarin.Forms_Performance_Integration-Signed-Release--Bundle.apkdesc
./Mono.Android_Tests-Signed-Release-.apkdesc
./Mono.Android_Tests-Signed-Release--Aot.apkdesc
./Xamarin.Forms_Performance_Integration-Signed-Release--Aot.apkdesc
./Xamarin.Android.Locale_Tests-Signed-Release-.apkdesc
./Mono.Android_Tests-Signed-Release--Bundle.apkdesc
./Xamarin.Android.JcwGen_Tests-Signed-Release-.apkdesc
./Xamarin.Android.Locale_Tests-Signed-Release--Aot.apkdesc
./Xamarin.Forms_Performance_Integration-Signed-Release--Profiled-Aot.apkdesc
./Mono.Android_TestsMultiDex-Signed-Release-.apkdesc
./Xamarin.Android.Locale_Tests-Signed-Release--Profiled-Aot.apkdesc
Note that many filenames have a trailing -, e.g. Xamarin.Android.JcwGen_Tests-Signed-Release-.apkdesc, or have --, e.g. Xamarin.Android.Locale_Tests-Signed-Release--Aot.apkdesc. I believe using just $(TestsFlavor) would fix this.
Visual Studio for Mac has a tendency to "re-format" `.csproj` files, e.g. if you add a new project to the `.sln`, it'll reformat *every* `.csproj` referenced by the `.sln`, and this "reformatting" invariably removes all "useful" whitespace, resulting in this "wonderful" fragment: ```xml <Target Name="CopyNewtonsoftJsonLicense" AfterTargets="Build"> <Copy SourceFiles="..\..\packages\newtonsoft.json\12.0.3\LICENSE.md" DestinationFiles="$(OutputPath)\Newtonsoft.Json-LICENSE.md" /> </Target> ``` To which I say NO. Custom targets do *not* go into the .csproj, precisely because VSMac will (eventually) screw it up. Move CopyNewtonsoftJsonLicense into `apkdiff.targets`, and then `<Import/>` apkdiff.targets.
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3452921&view=logs&j=8556562a-ae5f-5bd1-7c4d-bf1af4b6f1e1&t=1a8bc9f1-aacc-59ec-6634-323d2bcb90ae Shortly `apkdiff` was added (2e28f2e), some PR builds started showing errors around its execution: RecordApkSizes: "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/Darwin/apkdiff" -v -c "HEAD/`git branch --show-current`: `git rev-parse HEAD`" -s "../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed.aab";mv "../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed.apkdesc" "../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed-Release.apkdesc" EXEC : error : apkdiff: Unknown file extension '.aab' mv: rename ../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed.apkdesc to ../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed-Release.apkdesc: No such file or directory …/build-tools/scripts/TestApks.targets(354,5): error MSB3073: The command " "/Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/Darwin/apkdiff" -v -c "HEAD/`git branch --show-current`: `git rev-parse HEAD`" -s "../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed.aab";mv "../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed.apkdesc" "../../bin/TestRelease/Mono.Android_TestsAppBundle-Signed-Release.apkdesc" " exited with code 1. This error was likely overlooked in PR #4221 because PR builds are currently "noisy", with lots of "ignorable" errors occurring. Update `apkdiff` so that it will also process `.aab` files, thus avoiding the above error.
Context: https://github.com/xamarin/xamarin-android/projects/14
Context: #4191
And use it to produce
.apkdescfiles. These files will be later usedinstead of the size reference files we have now. They contain more
detailed size information and also improve the readability compared to
the
.csvfiles.The
.apkdescfiles look like: