Skip to content

[Microsoft.Android.Ref] support for older targetSdkVersion #4873

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

Closed
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
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 @@ -36,7 +36,7 @@ by projects that use the Microsoft.Android framework in .NET 5.
<_PackageFiles Include="@(_AndroidAppPackAssemblies)" PackagePath="$(_AndroidRefPackAssemblyPath)" TargetPath="$(_AndroidRefPackAssemblyPath)" />
<_PackageFiles Include="$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\netcoreapp3.1\mono.android.jar" PackagePath="$(_AndroidRefPackAssemblyPath)" />
<_PackageFiles Include="$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\netcoreapp3.1\mono.android.dex" PackagePath="$(_AndroidRefPackAssemblyPath)" />
<_PackageFiles Include="$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\netcoreapp3.1\AndroidApiInfo.xml" PackagePath="$(_AndroidRefPackAssemblyPath)" />
<_PackageFiles Include="$(XAInstallPrefix)xbuild-frameworks\MonoAndroid\*\AndroidApiInfo.xml" PackagePath="$(_AndroidRefPackAssemblyPath)\%(RecursiveDir)" />
</ItemGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ public void DotNetPublish ([Values (false, true)] bool isRelease)
FileAssert.Exists (aabSigned);
}

[Test]
public void TargetSdkVersion29 ()
{
var proj = new XASdkProject ();
proj.AndroidManifest = proj.AndroidManifest.Replace ("<uses-sdk />", "<uses-sdk android:targetSdkVersion=\"29\" />");
var dotnet = CreateDotNetBuilder (proj);
Assert.IsTrue (dotnet.Build (), "`dotnet build` should succeed");
}

[Test]
public void BuildWithLiteSdk ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static XASdkProject ()

public string PackageName { get; set; }
public string JavaPackageName { get; set; }
public string AndroidManifest { get; set; }

public XASdkProject (string outputType = "Exe")
{
Expand All @@ -51,13 +52,14 @@ public XASdkProject (string outputType = "Exe")

PackageName = PackageName ?? string.Format ("{0}.{0}", ProjectName);
JavaPackageName = JavaPackageName ?? PackageName.ToLowerInvariant ();
AndroidManifest = default_android_manifest;
GlobalPackagesFolder = Path.Combine (XABuildPaths.TopDirectory, "packages");
SetProperty (KnownProperties.OutputType, outputType);

// Add relevant Android content to our project without writing it to the .csproj file
if (outputType == "Exe") {
Sources.Add (new BuildItem.Source ("Properties\\AndroidManifest.xml") {
TextContent = () => default_android_manifest.Replace ("${PROJECT_NAME}", ProjectName).Replace ("${PACKAGENAME}", string.Format ("{0}.{0}", ProjectName))
TextContent = () => AndroidManifest.Replace ("${PROJECT_NAME}", ProjectName).Replace ("${PACKAGENAME}", string.Format ("{0}.{0}", ProjectName))
});
}
Sources.Add (new BuildItem.Source ($"MainActivity{Language.DefaultExtension}") { TextContent = () => ProcessSourceTemplate (MainActivity ?? DefaultMainActivity) });
Expand Down