Skip to content

Commit

Permalink
[Xamarin.Build.Download] remove AndroidAarFixups (#1368)
Browse files Browse the repository at this point in the history
Context: dotnet/runtime#68734

A breaking chang in in .NET 7 has uncovered an issue when using
Xamarin.Build.Download:

    Renaming: AndroidManifest.xml to AndroidManifest.xml
    ...
    (_XamarinBuildDownloadCore target) ->
        /Users/runner/.nuget/packages/xamarin.build.download/0.11.0/buildTransitive/Xamarin.Build.Download.targets(52,3): error XBD001: Download failed. Please download https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-basement/17.6.0/play-services-basement-17.6.0.aar to a file called /Users/runner/Library/Caches/XamarinBuildDownload/playservicesbasement-17.6.0.aar.
        /Users/runner/.nuget/packages/xamarin.build.download/0.11.0/buildTransitive/Xamarin.Build.Download.targets(52,3): error XBD001: Download failed. Please download https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-tasks/17.2.1/play-services-tasks-17.2.1.aar to a file called /Users/runner/Library/Caches/XamarinBuildDownload/playservicestasks-17.2.1.aar.
        /Users/runner/.nuget/packages/xamarin.build.download/0.11.0/buildTransitive/Xamarin.Build.Download.targets(52,3): error XBD001: Download failed. Please download https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-base/17.6.0/play-services-base-17.6.0.aar to a file called /Users/runner/Library/Caches/XamarinBuildDownload/playservicesbase-17.6.0.aar.
        /Users/runner/.nuget/packages/xamarin.build.download/0.11.0/buildTransitive/Xamarin.Build.Download.targets(52,3): error XBD001: Download failed. Please download https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/17.0.1/play-services-maps-17.0.1.aar to a file called /Users/runner/Library/Caches/XamarinBuildDownload/playservicesmaps-17.0.1.aar.
    1 Warning(s)
    4 Error(s)

The exception is somewhat swallowed here, the underlying error is
something like:

    System.InvalidOperationException : An entry named 'AndroidManifest.xml' already exists in the archive.

This class had various "fixups" to workaround issues in
Xamarin.Android. Many of these issues have long since been fixed.

1. Removal of `aapt/AndroidManifest.xml`. Xamarin.Android has been
   handling this since ~Sept 2018:

dotnet/android@f6c3288

2. Removal of `internal_impl-*.jar`. Xamarin.Android has been handling
   this since ~Feb 2018:

dotnet/android@6a8ea2b

3. Replacement of `android:name=".SomeService"` as shorthand for
   `androidx.foo.SomeService` in the `androidx.foo` package. The use
   of `manifest-merger` solves this issue completely. This setting is
   the default for .NET 6, and has been the default for AndroidX since
   ~July 2020:

dotnet/android-libraries@c6c0e50
  • Loading branch information
jonathanpeppers authored May 5, 2022
1 parent 895182c commit ccee49b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 139 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<_XamarinBuildDownloadIsAndroid>true</_XamarinBuildDownloadIsAndroid>
<_XamarinBuildDownloadMasterBeforeTargets>_ResolveLibraryProjectImports</_XamarinBuildDownloadMasterBeforeTargets>
<_XamarinBuildDownloadMasterDependsOnTargets>ResolveAssemblyReferences;_XamarinBuildDownload;_XamarinBuildDownloadAarRestore;_XamarinBuildDownloadAarInclude</_XamarinBuildDownloadMasterDependsOnTargets>
<_XamarinBuildDownloadAndroidFixManifests Condition="'$(_XamarinBuildDownloadAndroidFixManifests)' == ''">true</_XamarinBuildDownloadAndroidFixManifests>
</PropertyGroup>

<PropertyGroup Condition="'$(_XamarinBuildDownloadIsAndroid)'==''">
Expand Down Expand Up @@ -58,7 +57,6 @@
User7ZipPath="$(XamarinBuildDownloadUser7ZipPath)"
VsInstallRoot="$(VsInstallRoot)"
IsAndroid="$(_XamarinBuildDownloadIsAndroid)"
AndroidFixManifests="$(_XamarinBuildDownloadAndroidFixManifests)"
/>
</Target>

Expand All @@ -69,7 +67,6 @@
Parts="@(XamarinBuildDownloadPartialZip)"
CacheDirectory="$(XamarinBuildDownloadDir)"
IsAndroid="$(_XamarinBuildDownloadIsAndroid)"
AndroidFixManifests="$(_XamarinBuildDownloadAndroidFixManifests)"
/>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public class XamarinDownloadArchives : AsyncTask, ILogger

public bool IsAndroid { get; set; }

public bool AndroidFixManifests { get; set; }

DownloadUtils downloadUtils;

public override bool Execute ()
Expand Down Expand Up @@ -171,10 +169,6 @@ async Task<bool> MakeSureLibraryIsInPlace (XamarinBuildDownload xbd, Cancellatio
LogMessage (" Downloading {0} to {1}", xbd.Url, xbd.CacheFile);
client.DownloadFileTaskAsync (xbd.Url, xbd.CacheFile).Wait (token);

// Run through our AAR fixups if it's android
if (IsAndroid)
AndroidAarFixups.FixupAar(xbd.CacheFile, AndroidFixManifests, Log);

LogMessage (" Downloading Complete");
client.DownloadProgressChanged -= downloadHandler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class XamarinDownloadPartialZips : AsyncTask, ILogger

public bool IsAndroid { get; set; }

public bool AndroidFixManifests { get; set; }

HttpClient http;

public override bool Execute ()
Expand Down Expand Up @@ -178,10 +176,6 @@ async Task<bool> ExtractPartAndValidate (PartialZipDownload part, Stream partInp
return false;
}

// Run through our AAR fixups if it's android
if (IsAndroid)
AndroidAarFixups.FixupAar(outputPath, AndroidFixManifests, Log);

return true;
}

Expand Down

0 comments on commit ccee49b

Please sign in to comment.