Skip to content

Commit

Permalink
Merge branch 'main' into no-ndk-lib-stubs
Browse files Browse the repository at this point in the history
* main:
  Add Unit Test for testOnly apps (dotnet#7637)
  [build] Only build the latest API level (dotnet#7786)
  [Xamarin.Android.Build.Tasks] Improve aapt2+file not found handling (dotnet#7644)
  [MSBuildDeviceIntegration] Fix duplicated test parameter (dotnet#7809)
  • Loading branch information
grendello committed Feb 22, 2023
2 parents 2b53bd8 + 41748e1 commit 3b2cb45
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 207 deletions.
5 changes: 0 additions & 5 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@
<_StandardLibraryPath Condition=" '$(TargetFrameworkVersion)' == '' ">$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPathToStandardLibraries('.NETFramework', 'v4.7.2', ''))</_StandardLibraryPath>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' And '$(_StandardLibraryPath)' != '' ">v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' And '$(UsingMicrosoftNETSdk)' != 'true' ">v4.7.1</TargetFrameworkVersion>
<!-- Used by the `build-tools/create-vsix` build so that `Mono.Android.Export.dll`/etc. are only included *once* -->
<!-- Should correspond to the first value from `$(API_LEVELS)` in `build-tools/api-xml-adjuster/Makefile` -->
<AndroidFirstFrameworkVersion Condition="'$(AndroidFirstFrameworkVersion)' == ''">v4.4</AndroidFirstFrameworkVersion>
<AndroidFirstApiLevel Condition="'$(AndroidFirstApiLevel)' == ''">19</AndroidFirstApiLevel>
<AndroidJavaRuntimeApiLevel Condition="'$(AndroidJavaRuntimeApiLevel)' == ''">26</AndroidJavaRuntimeApiLevel>
<!-- The min API level supported by Microsoft.Android.Sdk, should refactor/remove when this value is the same as $(AndroidFirstApiLevel) -->
<AndroidMinimumDotNetApiLevel Condition="'$(AndroidMinimumDotNetApiLevel)' == ''">21</AndroidMinimumDotNetApiLevel>
<AndroidFirstPlatformId Condition="'$(AndroidFirstPlatformId)' == ''">$(AndroidFirstApiLevel)</AndroidFirstPlatformId>
<!-- *Latest* *stable* API level binding that we support; used when building src/Xamarin.Android.Build.Tasks -->
<AndroidLatestStableApiLevel Condition="'$(AndroidLatestStableApiLevel)' == ''">33</AndroidLatestStableApiLevel>
<AndroidLatestStablePlatformId Condition="'$(AndroidLatestStablePlatformId)' == ''">$(AndroidLatestStableApiLevel)</AndroidLatestStablePlatformId>
Expand Down
5 changes: 0 additions & 5 deletions Documentation/building/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ Overridable MSBuild properties include:
This is an integer value, e.g. `15` for
[API-15 (Android 4.0.3)](http://developer.android.com/about/versions/android-4.0.3.html).

* `$(AndroidFirstFrameworkVersion)`: The first `$(TargetFrameworkVersion)`
which will be built by `make jenkins` and included in the installer.
Currently `v4.4`.
This controls what is included in `build-tools/create-vsix` packages.

* `$(AndroidFrameworkVersion)`: The Xamarin.Android `$(TargetFrameworkVersion)`
version which corresponds to `$(AndroidApiLevel)`. This is *usually* the
Android version number with a leading `v`, e.g. `v4.0.3` for API-15.
Expand Down
1 change: 1 addition & 0 deletions Documentation/guides/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ms.date: 01/24/2020
+ APT0002: Invalid file name: It must contain only \[^a-zA-Z0-9_.-\]+.
+ APT0003: Invalid file name: It must contain only \[^a-zA-Z0-9_.\]+.
+ APT0004: Invalid file name: It must start with either A-Z or a-z or an underscore.
+ [APT2264](apt2264.md): The system cannot find the file specified. (2).

## JAVAxxxx: Java Tool

Expand Down
58 changes: 58 additions & 0 deletions Documentation/guides/messages/apt2264.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Xamarin.Android error APT2264
description: APT2264 error code
ms.date: 12/16/2022
---
# Xamarin.Android error APT2264

## Issue

The tool `aapt2` is unable to resolve one of the files it was passed.
This is generally caused by the path being longer than the Maximum Path
length allowed on windows.

## Solution

The best way to avoid this is to ensure that your project is not located
deep in the folder structure. For example if you create all of your
projects in folders such as

`C:\Users\shelly\Visual Studio\Android\MyProjects\Com.SomeReallyLongCompanyName.MyBrillantApplication\MyBrilliantApplicaiton.Android\`

you may well encounter problems with not only `aapt2` but also Ahead of Time
compilation. Keeping your project names and folder structures short and
concise will help work around these issues. For example instead of the above
you could use

`C:\Work\Android\MyBrilliantApp`

Which is much shorter and much less likely to encounter path issues.

However this is no always possible. Sometimes a project or a environment requires
deep folder structures. In this case enabling long path support in Windows *might*
be enough to get your project working. Details on how to do this can be found
[here](https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later).


If long path support does not work changing the location of the
`$(BaseIntermediateOutputPath)` can help solve these problems. In order for this
to work the setting MUST be changed before ANY build or restore occurs. To do this
you can make use of the MSBuild `Directory.Build.props` support.

Creating a `Directory.Build.props` file in your solution or project directory which
redefines the `$(BaseIntermediateOutputPath)` to somewhere nearer the root of the drive
with solve these issues. Adding a file with the following contents will create the `obj`
directory in a different location of your choosing.

```
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath Condition=" '$(OS)' == 'Windows_NT' ">C:\Intermediate\$(ProjectName)</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition=" '$(OS)' != 'Windows_NT' ">/tmp/Intermediate/$(ProjectName)</BaseIntermediateOutputPath>
</PropertyGroup>
</Project
```

Using this technique will reduce the lengths of the paths sent to the various tools like `aapt2`.
Note this is generally only a Windows issue. So there is no need to override the `$(BaseIntermediateOutputPath)`
on Mac or Linux based environments. However you might want to override everywhere to be consistent.
2 changes: 1 addition & 1 deletion build-tools/api-xml-adjuster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ API_XML_TOOL = $(BUILDBIN)/api-xml-adjuster.exe
RUNTIME = mono --debug
RUN_CLASS_PARSE = $(RUNTIME) $(CLASS_PARSE)
RUN_API_XML_TOOL = $(RUNTIME) $(API_XML_TOOL)
API_LEVELS = 10 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
API_LEVELS = 33

XML_OUTPUT_DIR = .

Expand Down
176 changes: 0 additions & 176 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ resources:
name: xamarin/release-scripts
ref: refs/heads/sign-and-notarized
endpoint: xamarin
- repository: uitools
type: github
name: xamarin/UITools
ref: refs/heads/main
endpoint: xamarin

parameters:
- name: provisionatorChannel
Expand Down Expand Up @@ -697,11 +692,6 @@ stages:
target_framework: $(DotNetStableTargetFramework)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- stage: wear_tests
displayName: WearOS Tests
dependsOn: mac_build
condition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'MSBuildDevice')))
jobs:
- job: wear_tests
displayName: macOS > Tests > WearOS
timeoutInMinutes: 180
Expand Down Expand Up @@ -771,172 +761,6 @@ stages:
- template: yaml-templates/fail-on-issue.yaml



- stage: designer_tests
displayName: Designer Tests
dependsOn: mac_build
condition: and(succeeded(), or(eq(variables['RunAllTests'], true), contains(dependencies.mac_build.outputs['mac_build_create_installers.TestConditions.TestAreas'], 'Designer')))
jobs:
# Check - "Xamarin.Android (macOS > Tests > Designer Integration)"
- job: designer_integration_mac
condition: false #TODO: Enable once test issues are fixed.
displayName: macOS > Tests > Designer Integration
pool:
vmImage: $(HostedMacImage)
timeoutInMinutes: 120
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
EnableRegressionTest: true
steps:
- checkout: uitools
clean: true
submodules: recursive
path: s/UITools
persistCredentials: true

- powershell: |
# Use the branch name of the source being built or the PR target branch name. Fall back to 'main' if the branch is unknown.
$branchPrefix = "/refs/heads/"
$branchName = "$(Build.SourceBranch)" -replace $branchPrefix, ""
if ("$(Build.Reason)" -eq "PullRequest") {
$branchName = "$(System.PullRequest.TargetBranch)" -replace $branchPrefix, ""
}
if (("$branchName" -ne "main") -and ("$branchName" -notlike "d1*")) {
$branchName = "main"
}
Set-Location -Path $(System.DefaultWorkingDirectory)/UITools
git checkout $branchName
git submodule update -q --init --recursive
displayName: Clone and update UITools
- task: NuGetAuthenticate@0
displayName: authenticate with azure artifacts
inputs:
forceReinstallCredentialProvider: true

- task: provisionator@2
displayName: provision designer dependencies
inputs:
github_token: $(GitHub.Token)
provisioning_script: $(System.DefaultWorkingDirectory)/UITools/src/bot-provisioning/dependencies.csx
provisioning_extra_args: -remove Xamarin.Android -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token)
env:
PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }}

- template: yaml-templates/setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android
jdkTestFolder: $(JAVA_HOME_8_X64)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- template: designer/android-designer-build-mac.yaml@yaml-templates
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)/UITools/src

- template: designer/android-designer-tests.yaml@yaml-templates
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)/UITools/src
runAddinTests: false

- task: CopyFiles@2
displayName: 'Copy binlogs'
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/UITools/src/Xamarin.Designer.Android
contents: '**/*.binlog'
targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs
overWrite: true
flattenFolders: true
condition: ne(variables['Agent.JobStatus'], 'Succeeded')

- template: yaml-templates/publish-artifact.yaml
parameters:
displayName: upload designer binlogs
artifactName: Test Results - Designer - macOS
targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs
condition: ne(variables['Agent.JobStatus'], 'Succeeded')

# Check - "Xamarin.Android (Windows > Tests > Designer Integration)"
- job: designer_integration_win
displayName: Windows > Tests > Designer Integration
pool:
vmImage: $(HostedWinImage)
timeoutInMinutes: 120
cancelTimeoutInMinutes: 5
workspace:
clean: all
variables:
EnableRegressionTest: true
RegressionTestSuiteOutputDir: C:\Git\ADesRegTestSuite
VisualStudioInstallationPath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise
steps:
- checkout: uitools
clean: true
submodules: recursive
path: s\UITools
persistCredentials: true

- powershell: |
# Use the branch name of the source being built or the PR target branch name. Fall back to 'main' if the branch is unknown.
$branchPrefix = "/refs/heads/"
$branchName = "$(Build.SourceBranch)" -replace $branchPrefix, ""
if ("$(Build.Reason)" -eq "PullRequest") {
$branchName = "$(System.PullRequest.TargetBranch)" -replace $branchPrefix, ""
}
if (("$branchName" -ne "main") -and ("$branchName" -notlike "d1*")) {
$branchName = "main"
}
Set-Location -Path $(System.DefaultWorkingDirectory)\UITools
git checkout $branchName
git submodule update -q --init --recursive
displayName: Clone and update UITools
- task: NuGetAuthenticate@0
displayName: authenticate with azure artifacts
inputs:
forceReinstallCredentialProvider: true

- task: provisionator@2
displayName: provision designer dependencies
inputs:
github_token: $(GitHub.Token)
provisioning_script: $(System.DefaultWorkingDirectory)\UITools\src\bot-provisioning\dependencies.csx
provisioning_extra_args: -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token)
env:
PROVISIONATOR_CHANNEL: ${{ parameters.provisionatorChannel }}

- template: yaml-templates\setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)\xamarin-android
jdkTestFolder: $(JAVA_HOME_8_X64)
provisionatorChannel: ${{ parameters.provisionatorChannel }}

- task: VSBuild@1
displayName: Restore Xamarin.AndroidDesigner
inputs:
solution: $(System.DefaultWorkingDirectory)\UITools\src\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln
vsVersion: 17.0
msbuildArgs: >-
/t:Restore /p:RestoreDisableParallel=true
/p:RestoreConfigFile="$(System.DefaultWorkingDirectory)\UITools\NuGet.Config"
/p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
platform: Any CPU
configuration: DebugWin32

- task: VSBuild@1
displayName: Build Xamarin.AndroidDesigner
inputs:
solution: $(System.DefaultWorkingDirectory)\UITools\src\Xamarin.Designer.Android\Xamarin.AndroidDesigner.sln
vsVersion: 17.0
msbuildArgs: /t:Build /p:GitHubToken=$(GitHub.Token)
platform: Any CPU
configuration: DebugWin32

- template: yaml-templates/run-designer-tests.yml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)\UITools\src

- stage: bcl_tests
displayName: BCL Emulator Tests
dependsOn: mac_build
Expand Down
1 change: 0 additions & 1 deletion build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<LegacyMSBuildSrcDir>$(XAInstallPrefix)xbuild\Xamarin\Android\</LegacyMSBuildSrcDir>
<MSBuildTargetsSrcDir>$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\MSBuild\Xamarin\Android</MSBuildTargetsSrcDir>
<DefaultRuntimeEntitlementsPath>$(MSBuildThisFileDirectory)\..\create-pkg\runtime-entitlements.plist</DefaultRuntimeEntitlementsPath>
<FirstInstallerFrameworkVersion Condition="Exists('$(FrameworkSrcDir)\$(AndroidFirstFrameworkVersion)')">$(AndroidFirstFrameworkVersion)</FirstInstallerFrameworkVersion>
<FirstInstallerFrameworkVersion Condition="'$(FirstInstallerFrameworkVersion)' == ''">$(AndroidLatestStableFrameworkVersion)</FirstInstallerFrameworkVersion>
<BclFrameworkVersion>v1.0</BclFrameworkVersion>
<LibExtension Condition=" '$(HostOS)' == 'Darwin' ">dylib</LibExtension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ class BuildAndroidPlatforms
new AndroidPlatform (apiName: "Jelly Bean", apiLevel: 16, platformID: "16", include: "v4.1"),
new AndroidPlatform (apiName: "Jelly Bean", apiLevel: 17, platformID: "17", include: "v4.2"),
new AndroidPlatform (apiName: "Jelly Bean", apiLevel: 18, platformID: "18", include: "v4.3"),
new AndroidPlatform (apiName: "Kit Kat", apiLevel: 19, platformID: "19", include: "v4.4", framework: "v4.4"),
new AndroidPlatform (apiName: "Kit Kat + Wear support", apiLevel: 20, platformID: "20", include: "v4.4.87", framework: "v4.4.87"),
new AndroidPlatform (apiName: "Lollipop", apiLevel: 21, platformID: "21", include: "v5.0", framework: "v5.0"),
new AndroidPlatform (apiName: "Lollipop", apiLevel: 22, platformID: "22", include: "v5.1", framework: "v5.1"),
new AndroidPlatform (apiName: "Marshmallow", apiLevel: 23, platformID: "23", include: "v6.0", framework: "v6.0"),
new AndroidPlatform (apiName: "Nougat", apiLevel: 24, platformID: "24", include: "v7.0", framework: "v7.0"),
new AndroidPlatform (apiName: "Nougat", apiLevel: 25, platformID: "25", include: "v7.1", framework: "v7.1"),
new AndroidPlatform (apiName: "Oreo", apiLevel: 26, platformID: "26", include: "v8.0", framework: "v8.0"),
new AndroidPlatform (apiName: "Oreo", apiLevel: 27, platformID: "27", include: "v8.1", framework: "v8.1"),
new AndroidPlatform (apiName: "Pie", apiLevel: 28, platformID: "28", include: "v9.0", framework: "v9.0"),
new AndroidPlatform (apiName: "Q", apiLevel: 29, platformID: "29", include: "v10.0", framework: "v10.0"),
new AndroidPlatform (apiName: "R", apiLevel: 30, platformID: "30", include: "v11.0", framework: "v11.0"),
new AndroidPlatform (apiName: "S", apiLevel: 31, platformID: "31", include: "v12.0", framework: "v12.0"),
new AndroidPlatform (apiName: "Sv2", apiLevel: 32, platformID: "32", include: "v12.1", framework: "v12.1"),
new AndroidPlatform (apiName: "Kit Kat", apiLevel: 19, platformID: "19", include: "v4.4"),
new AndroidPlatform (apiName: "Kit Kat + Wear support", apiLevel: 20, platformID: "20", include: "v4.4.87"),
new AndroidPlatform (apiName: "Lollipop", apiLevel: 21, platformID: "21", include: "v5.0"),
new AndroidPlatform (apiName: "Lollipop", apiLevel: 22, platformID: "22", include: "v5.1"),
new AndroidPlatform (apiName: "Marshmallow", apiLevel: 23, platformID: "23", include: "v6.0"),
new AndroidPlatform (apiName: "Nougat", apiLevel: 24, platformID: "24", include: "v7.0"),
new AndroidPlatform (apiName: "Nougat", apiLevel: 25, platformID: "25", include: "v7.1"),
new AndroidPlatform (apiName: "Oreo", apiLevel: 26, platformID: "26", include: "v8.0"),
new AndroidPlatform (apiName: "Oreo", apiLevel: 27, platformID: "27", include: "v8.1"),
new AndroidPlatform (apiName: "Pie", apiLevel: 28, platformID: "28", include: "v9.0"),
new AndroidPlatform (apiName: "Q", apiLevel: 29, platformID: "29", include: "v10.0"),
new AndroidPlatform (apiName: "R", apiLevel: 30, platformID: "30", include: "v11.0"),
new AndroidPlatform (apiName: "S", apiLevel: 31, platformID: "31", include: "v12.0"),
new AndroidPlatform (apiName: "Sv2", apiLevel: 32, platformID: "32", include: "v12.1"),
new AndroidPlatform (apiName: "Tiramisu", apiLevel: 33, platformID: "33", include: "v13.0", framework: "v13.0"),
};

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ Please change the value to an assembly-qualifed type name which inherits from '{
<comment>The following are literal names and should not be translated: Java.Interop.DoNotPackageAttribute
{0} - The assembly name</comment>
</data>
<data name="APT2264" xml:space="preserve">
<value>This is probably caused by the project exceeding the Windows maximum path length limitation. See https://learn.microsoft.com/xamarin/android/errors-and-warnings/apt2264 for details.</value>
<comment>The following are literal names and should not be translated:</comment>
</data>
<data name="XA3001" xml:space="preserve">
<value>Could not AOT the assembly: {0}</value>
<comment>The abbreviation "AOT" should not be translated.</comment>
Expand Down
Loading

0 comments on commit 3b2cb45

Please sign in to comment.