Commit f1cee97
committed
[Xamarin.Android.Build.Tasks] _AddMultiDexDependencyJars only runs for apps
Context: dotnet/android-libraries#247
When porting AndroidX to .NET 6, I noticed something odd... I was
getting `.aar` files in the build output that appeared to contain the
contents of `android-support-multidex.jar`.
Then I noticed:
https://github.com/xamarin/AndroidX/blob/16b02ae51980f7bab7be395d44f9998eea9bf32f/source/AndroidXProject.cshtml#L18
The AndroidX binding projects are setting `$(AndroidEnableMultiDex)`?
This is surely not intentional to be set in a class library, but this
causes `_AddMultiDexDependencyJars` to run:
<Target Name="_AddMultiDexDependencyJars">
<!-- ... -->
<ItemGroup Condition=" '$(AndroidEnableMultiDex)' == 'True' AND '$(AndroidMultiDexSupportJar)' == '' ">
<AndroidJavaLibrary Include="$(MonoAndroidToolsDirectory)\android-support-multidex.jar" />
</ItemGroup>
</Target>
If this was added to `@(AndroidJavaLibrary)`, then the `<CreateAar/>`
MSBuild task would happily package it in a .NET 6 class library!
I think the solution here is that the `_AddMultiDexDependencyJars`
MSBuild target shouldn't actually run unless `$(AndroidApplication)`
is `true`.
I added updated an existing test for this scenario.1 parent dc1f7ba commit f1cee97
File tree
2 files changed
+23
-1
lines changed- src/Xamarin.Android.Build.Tasks
- Tests/Xamarin.Android.Build.Tests
2 files changed
+23
-1
lines changedLines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
181 | 202 | | |
182 | 203 | | |
183 | 204 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1021 | 1021 | | |
1022 | 1022 | | |
1023 | 1023 | | |
1024 | | - | |
| 1024 | + | |
| 1025 | + | |
1025 | 1026 | | |
1026 | 1027 | | |
1027 | 1028 | | |
| |||
0 commit comments