Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/ISSUE_TEMPLATE/04-binding-a-java-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ assignees: 'jpobst'

---

### Steps to Reproduce
<!--

1.
2.
3.
Documentation for how to troubleshoot issues with binding projects, as well as common issues and how to solve them, is available here:

https://github.com/xamarin/java.interop/wiki/Troubleshooting-Android-Bindings-Issues

<!--
If you have a repro project, you may drag & drop the .zip/etc. onto the issue editor to attach it.
-->

### Expected Behavior
### Error Message or Issue



### Actual Behavior

### Version Information

<details>
<!--
1. On macOS and within Visual Studio, select Visual Studio > About Visual Studio, then click the Show Details button, then click the Copy Information button.

1. In the Visual Studio menus, select 'Visual Studio' > 'About Visual Studio', then click the 'Show Details' button, then click the 'Copy Information' button.

2. Paste below this comment block.

-->


Expand All @@ -38,12 +39,19 @@ If you have a repro project, you may drag & drop the .zip/etc. onto the issue ed
### Log File

<!--

Some useful binding logging is only available with MSBuild Diagnostic logging enabled.

Enable [Diagnostic logging](https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/troubleshooting#diagnostic-msbuild-output), **Rebuild** (not just Build) your project, and attach the log.

-->


### Other Helpful Info

<!--
Switch to the "Preview" tab to ensure your issue renders correctly.

If you have other things that might be helpful, like the .jar or .aar you are trying to bind, or a sample project that reproduces the error, please drag and drop to attach it to this issue.

-->

1 change: 1 addition & 0 deletions Documentation/workflow/HowToAddNewApiLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ the new platform will be downloaded to your local Android SDK.
- Read the note at the bottom of `/src/Mono.Android/metadata` that has a few lines that must be
copy/pasted for new API levels
- Add required metadata fixes in `/src/Mono.Android/metadata` until `Mono.Android.csproj` builds
- Check that new package/namespaces are properly cased

### ApiCompat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public class GenerateWixFile : Task
[Required]
public string DotNetPath { get; set; }

[Required]
public string DotNetVersion { get; set; }

[Required]
public string MSIVersion { get; set; }

Expand All @@ -44,38 +41,12 @@ public override bool Execute ()
// Components
componentWriter.WriteStartElement ("ComponentGroup");
componentWriter.WriteAttributeString ("Id", "ProductComponents");
componentWriter.WriteStartElement ("ComponentRef");
componentWriter.WriteAttributeString ("Id", "EnableWorkloadResolver");
componentWriter.WriteEndElement (); // </ComponentRef>

// dotnet
packWriter.WriteStartElement ("Directory");
packWriter.WriteAttributeString ("Id", "dotnet");
packWriter.WriteAttributeString ("Name", "dotnet");

// sdk
packWriter.WriteStartElement ("Directory");
packWriter.WriteAttributeString ("Id", "sdk");
packWriter.WriteAttributeString ("Name", "sdk");

// DOTNETVERSION
packWriter.WriteStartElement ("Directory");
packWriter.WriteAttributeString ("Id", "DOTNETVERSION");
packWriter.WriteAttributeString ("Name", DotNetVersion);
packWriter.WriteAttributeString ("FileSource", Path.Combine (DotNetPath, "sdk", DotNetVersion));

// EnableWorkloadResolver
packWriter.WriteStartElement ("Component");
packWriter.WriteAttributeString ("Id", "EnableWorkloadResolver");
packWriter.WriteStartElement ("File");
packWriter.WriteAttributeString ("Id", "EnableWorkloadResolver");
packWriter.WriteAttributeString ("Name", "EnableWorkloadResolver.sentinel");
packWriter.WriteAttributeString ("KeyPath", "yes");
packWriter.WriteEndElement (); // </File>
packWriter.WriteEndElement (); // </Component>
packWriter.WriteEndElement (); // </Directory> DOTNETVERSION
packWriter.WriteEndElement (); // </Directory> sdk

// sdk-manifests
var sdk_manifests_root = Path.Combine (DotNetPath, "sdk-manifests");
packWriter.WriteStartElement ("Directory");
Expand All @@ -93,7 +64,7 @@ public override bool Execute ()
packWriter.WriteAttributeString ("Id", "DOTNETVERSIONBAND");
packWriter.WriteAttributeString ("Name", version_band);
packWriter.WriteAttributeString ("FileSource", sdk_manifests);
var workload = Path.Combine (sdk_manifests, "Microsoft.NET.Workload.Android");
var workload = Path.Combine (sdk_manifests, "Microsoft.NET.Sdk.Android");
if (Directory.Exists (workload)) {
RecurseDirectory (sdk_manifests, packWriter, componentWriter, workload);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ steps:
parameters:
provisionExtraArgs: ${{ parameters.provisionExtraArgs }}

- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/${{ parameters.jdkTestFolder }}"
- script: |
echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/${{ parameters.jdkTestFolder }}"
echo "##vso[task.setvariable variable=DOTNET_TOOL_PATH]$HOME/Library/Android/dotnet/dotnet"
displayName: set JI_JAVA_HOME
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))

- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\${{ parameters.jdkTestFolder }}
echo ##vso[task.setvariable variable=DOTNET_TOOL_PATH]%USERPROFILE%\android-toolchain\dotnet\dotnet.exe
displayName: set JI_JAVA_HOME
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))

Expand Down
3 changes: 1 addition & 2 deletions build-tools/create-dotnet-msi/create-dotnet-msi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<Target Name="_Properties">
<PropertyGroup>
<License Condition=" '$(License)' == '' ">$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Workload.Android\LICENSE</License>
<License Condition=" '$(License)' == '' ">$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Sdk.Android\LICENSE</License>
<_LicenseDestination>$(IntermediateOutputPath)LICENSE.rtf</_LicenseDestination>
<_WixFile>$(IntermediateOutputPath)Microsoft.NET.Workload.Android.wix</_WixFile>
<_WixObj>$(IntermediateOutputPath)Microsoft.NET.Workload.Android.wixobj</_WixObj>
Expand Down Expand Up @@ -74,7 +74,6 @@
Template="$(_WixTemplate)"
DestinationFile="$(_WixFile)"
DotNetPath="$(DotNetPreviewPath)"
DotNetVersion="$(MicrosoftDotnetSdkInternalPackageVersion)"
MSIVersion="$(AndroidMSIVersion)"
/>
<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions build-tools/create-dotnet-pkg/create-dotnet-pkg.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
<Target Name="_FinalizePayload"
DependsOnTargets="GetXAVersionInfo">
<PropertyGroup>
<License Condition=" '$(License)' == '' ">$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Workload.Android\LICENSE</License>
<License Condition=" '$(License)' == '' ">$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Sdk.Android\LICENSE</License>
<DotNetPayloadDir>$(PayloadDir)\usr\local\share\dotnet\</DotNetPayloadDir>
</PropertyGroup>
<ItemGroup>
<_FilesToCopy Include="$(DotNetPreviewPath)\sdk\$(MicrosoftDotnetSdkInternalPackageVersion)\EnableWorkloadResolver.sentinel" />
<_FilesToCopy Include="$(DotNetPreviewPath)\sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Workload.Android\**\*" />
<_FilesToCopy Include="$(DotNetPreviewPath)\sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Sdk.Android\**\*" />
<_FilesToCopy Include="$(DotNetPreviewPath)\packs\Microsoft.Android.Ref\**\*" />
<_FilesToCopy Include="$(DotNetPreviewPath)\packs\Microsoft.Android.Sdk.Darwin\**\*" />
<_FilesToCopy Include="$(DotNetPreviewPath)\packs\Microsoft.Android.Sdk.BundleTool\**\*" />
Expand Down
2 changes: 2 additions & 0 deletions build-tools/create-packs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
<NoWarn>$(NoWarn);NU5128;NU5131</NoWarn>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />

</Project>
21 changes: 6 additions & 15 deletions build-tools/create-packs/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<Project>
<Import Project="..\..\Configuration.props" />

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Feed" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Packaging" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" PrivateAssets="all" />
Expand All @@ -15,7 +13,6 @@

<PropertyGroup>
<_MonoAndroidNETOutputDir>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\net6.0\</_MonoAndroidNETOutputDir>
<_WorkloadResolverFlagFile>$(DotNetPreviewPath)sdk\$(MicrosoftDotnetSdkInternalPackageVersion)\EnableWorkloadResolver.sentinel</_WorkloadResolverFlagFile>
</PropertyGroup>

<!-- LICENSE setup -->
Expand Down Expand Up @@ -87,14 +84,14 @@
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:HostOS=Darwin &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' == 'Darwin' " />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:HostOS=Windows &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' != 'Linux' " /> <!-- Windows pack should be built both Windows and macOS -->
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.BundleTool.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.NET.Workload.Android.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Android.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj&quot;" />
</Target>

<Target Name="ExtractWorkloadPacks"
DependsOnTargets="DeleteExtractedWorkloadPacks" >
<ItemGroup>
<_WLManifest Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.NET.Workload.Android.*.nupkg" />
<_WLManifest Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.NET.Sdk.Android.Manifest-*.nupkg" />
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.$(HostOS).*.nupkg" />
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.BundleTool.*.nupkg" />
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Ref.*.nupkg" />
Expand All @@ -103,7 +100,7 @@
<!-- <_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Runtime.*.nupkg" /> -->
</ItemGroup>
<PropertyGroup>
<_WLPackVersion>@(_WLManifest->'%(Filename)'->Replace('Microsoft.NET.Workload.Android.', ''))</_WLPackVersion>
<_WLPackVersion>@(_WLManifest->'%(Filename)'->Replace('Microsoft.NET.Sdk.Android.Manifest-$(DotNetPreviewVersionBand).', ''))</_WLPackVersion>
<_SdkManifestsFolder>$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\</_SdkManifestsFolder>
</PropertyGroup>
<Unzip
Expand All @@ -115,7 +112,7 @@
<_WLExtractedFiles Include="$(_SdkManifestsFolder)temp\LICENSE" />
<_WLExtractedFiles Include="$(_SdkManifestsFolder)temp\data\*" />
</ItemGroup>
<Move SourceFiles="@(_WLExtractedFiles)" DestinationFolder="$(_SdkManifestsFolder)Microsoft.NET.Workload.Android" />
<Move SourceFiles="@(_WLExtractedFiles)" DestinationFolder="$(_SdkManifestsFolder)Microsoft.NET.Sdk.Android" />
<RemoveDir Directories="$(_SdkManifestsFolder)temp\" />
<Unzip
SourceFiles="@(_WLPacks)"
Expand All @@ -126,7 +123,7 @@
<Copy SourceFiles="@(_WLTemplates)" DestinationFiles="@(_WLTemplates->'%(Filename)%(Extension)'->ToLower()->'$(DotNetPreviewPath)template-packs\%(Identity)')" />
<ItemGroup>
<_UnixExecutables Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.*\*\tools\$(HostOS)\**\*.*" />
<_FilesToTouch Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Workload.Android\**" />
<_FilesToTouch Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Sdk.Android\**" />
<_FilesToTouch Include="$(DotNetPreviewPath)packs\$([System.String]::Copy('%(_WLPacks.Filename)').Replace('.$(_WLPackVersion)', ''))\$(_WLPackVersion)\**" />
</ItemGroup>
<Exec
Expand All @@ -135,22 +132,16 @@
/>
<!-- Some files had timestamps in the future -->
<Touch Files="@(_FilesToTouch)" />
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName ($(_WorkloadResolverFlagFile)))" />
<Touch
Files="$(_WorkloadResolverFlagFile)"
AlwaysCreate="true"
/>
</Target>

<Target Name="DeleteExtractedWorkloadPacks" >
<ItemGroup>
<_PackFilesToDelete Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.Android.Workload\**\*.*" />
<_PackFilesToDelete Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Sdk.Android\**\*.*" />
<_PackFilesToDelete Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Workload.Android\**\*.*" />
<_PackFilesToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android*\**\*.*" />
<_PackFilesToDelete Include="$(DotNetPreviewPath)template-packs\Microsoft.Android.Templates.*.nupkg" />
</ItemGroup>
<RemoveDir Directories="%(_PackFilesToDelete.RootDir)%(_PackFilesToDelete.Directory)" />
<Delete Files="$(_WorkloadResolverFlagFile)" />
</Target>

<Target Name="PushManifestToBuildAssetRegistry" >
Expand Down
2 changes: 1 addition & 1 deletion build-tools/create-packs/Microsoft.Android.Ref.proj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ by projects that use the Microsoft.Android framework in .NET 5.
</PropertyGroup>

<ItemGroup>
<_AndroidRefPackAssemblies Include="$(JavaInteropSourceDirectory)\bin\$(Configuration)-netcoreapp3.1\ref\Java.Interop.dll" />
<_AndroidRefPackAssemblies Include="$(JavaInteropSourceDirectory)\bin\$(Configuration)-net6.0\ref\Java.Interop.dll" />
<_AndroidRefPackAssemblies Include="$(_MonoAndroidNETOutputDir)ref\Mono.Android.dll" />
<_AndroidRefPackAssemblies Include="$(_MonoAndroidNETOutputDir)ref\Mono.Android.Export.dll" />
<FrameworkListFileClass Include="@(_AndroidRefPackAssemblies->'%(Filename)%(Extension)')" Profile="Android" />
Expand Down
4 changes: 2 additions & 2 deletions build-tools/create-packs/Microsoft.Android.Sdk.proj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
***********************************************************************************************
Microsoft.Android.Sdk.proj

This project file is used to create the Microsoft.Android.Sdk.$(RID) NuGets, which are the
core workload sdk packs imported by Microsoft.NET.Workload.Android.
This project file is used to create the Microsoft.Android.Sdk.$(HostOS) NuGets, which are the
core workload SDK packs imported by WorkloadManifest.targets.
***********************************************************************************************
-->
<Project Sdk="Microsoft.Build.NoTargets">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<!--
***********************************************************************************************
Microsoft.NET.Workload.Android.proj
Microsoft.NET.Sdk.Android.proj

This project file is used to create the Microsoft.NET.Workload.Android NuGet, which is the
workload manifest pack containing information about the various Microsoft.Android workloads.
This project file is used to create the Microsoft.NET.Sdk.Android
NuGet, which is the workload manifest pack containing information
about the various Microsoft.Android workloads.
***********************************************************************************************
-->
<Project Sdk="Microsoft.Build.NoTargets">

<PropertyGroup>
<PackageId>Microsoft.NET.Workload.Android</PackageId>
<Description>Microsoft.Android workload manifest. Please do not reference directly.</Description>
<PackageId>Microsoft.NET.Sdk.Android.Manifest-$(DotNetPreviewVersionBand)</PackageId>
<Description>Microsoft.NET.Sdk.Android workload manifest. Please do not reference directly.</Description>
</PropertyGroup>

<UsingTask AssemblyFile="$(PrepTasksAssembly)" TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" />
Expand All @@ -31,13 +32,13 @@ workload manifest pack containing information about the various Microsoft.Androi

<MakeDir Directories="$([System.IO.Path]::GetDirectoryName ($(WorkloadManifestJsonPath)))" />
<ReplaceFileContents
SourceFile="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.NET.Workload.Android\WorkloadManifest.in.json"
SourceFile="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.NET.Sdk.Android\WorkloadManifest.in.json"
DestinationFile="$(WorkloadManifestJsonPath)"
Replacements="@SDK_PACK_VERSION@=$(AndroidPackVersionLong);@REF_PACK_VERSION@=$(AndroidPackVersionLong);@TEMPLATE_PACK_VERSION@=$(AndroidPackVersionLong);">
Replacements="@WORKLOAD_VERSION@=$(AndroidPackVersionLong)">
</ReplaceFileContents>

<ItemGroup>
<_PackageFiles Include="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.NET.Workload.Android\WorkloadManifest.targets" PackagePath="data" />
<_PackageFiles Include="$(XamarinAndroidSourcePath)src\Xamarin.Android.Build.Tasks\Microsoft.NET.Sdk.Android\WorkloadManifest.targets" PackagePath="data" />
<_PackageFiles Include="$(WorkloadManifestJsonPath)" PackagePath="data" />
</ItemGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public AndroidToolchain ()
new AndroidPlatformComponent ("platform-28_r04", apiLevel: "28", pkgRevision: "4"),
new AndroidPlatformComponent ("platform-29_r01", apiLevel: "29", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-30_r01", apiLevel: "30", pkgRevision: "1"),
new AndroidPlatformComponent ("platform-S_r02", apiLevel: "S", pkgRevision: "2"),
new AndroidPlatformComponent ("platform-S_r03", apiLevel: "S", pkgRevision: "3"),

new AndroidToolchainComponent ("sources-30_r01", destDir: Path.Combine ("platforms", $"android-30", "src"), pkgRevision: "1", dependencyType: AndroidToolchainComponentType.BuildDependency),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
<JavaCPath Condition=" '$(JavaCPath)' == '' ">@javac@</JavaCPath>
<JarPath Condition=" '$(JarPath)' == '' ">@jar@</JarPath>
<JavaSdkDirectory Condition=" '$(JavaSdkDirectory)' == '' ">@javahome@</JavaSdkDirectory>
<DotnetToolPath Condition=" '$(DotnetToolPath)' == '' ">@dotnet@</DotnetToolPath>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ partial void AddOSSpecificSteps (Context context, List<GeneratedFile> steps)
string jdkJvmPath = Path.Combine (javaSdkDirectory, "jre", "bin", "server", "jvm.dll");
string jdkIncludePathShared = Path.Combine (javaSdkDirectory, "include");
string jdkIncludePathOS = Path.Combine (jdkIncludePathShared, "win32");
var dotnetPath = context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath);
var dotnetTool = Path.Combine (dotnetPath, "dotnet");

var replacements = new Dictionary<string, string> (StringComparer.Ordinal) {
{ "@JdkJvmPath@", jdkJvmPath },
Expand All @@ -24,6 +26,7 @@ partial void AddOSSpecificSteps (Context context, List<GeneratedFile> steps)
{ "@java@", context.OS.JavaPath },
{ "@jar@", context.OS.JarPath },
{ "@javahome@", context.OS.JavaHome },
{ "@dotnet@", dotnetTool },
};

var step = new GeneratedPlaceholdersFile (
Expand Down
Loading