diff --git a/src/Mono.Android/Android.Runtime/JNIEnvInit.cs b/src/Mono.Android/Android.Runtime/JNIEnvInit.cs index 097c8e5d0ab..dc4fb8f5823 100644 --- a/src/Mono.Android/Android.Runtime/JNIEnvInit.cs +++ b/src/Mono.Android/Android.Runtime/JNIEnvInit.cs @@ -178,9 +178,7 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args) args->propagateUncaughtExceptionFn = (IntPtr)(delegate* unmanaged)&PropagateUncaughtException; - if (!RuntimeFeature.TrimmableTypeMap) { - args->registerJniNativesFn = (IntPtr)(delegate* unmanaged)&RegisterJniNatives; - } + args->registerJniNativesFn = (IntPtr)(delegate* unmanaged)&RegisterJniNatives; RunStartupHooksIfNeeded (); SetSynchronizationContext (); } diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets index d38aad44fb9..d83ac767f5d 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets @@ -14,7 +14,6 @@ <_TypeMapBaseOutputDir>$(IntermediateOutputPath) <_TypeMapBaseOutputDir>$(_TypeMapBaseOutputDir.Replace('\','/')) <_TypeMapOutputDirectory>$(_TypeMapBaseOutputDir)typemap/ - <_TypeMapJavaOutputDirectory>$(_TypeMapBaseOutputDir)typemap/java @@ -55,7 +54,7 @@ - - <_TypeMapJavaFiles Include="$(_TypeMapJavaOutputDirectory)/**/*.java" /> - - - - - - - <_TypeMapFirstAbi Condition=" '$(AndroidSupportedAbis)' != '' ">$([System.String]::Copy('$(AndroidSupportedAbis)').Split(';')[0]) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index a8a90ae9ff3..a67d06dd2c8 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -845,6 +845,50 @@ public void BuildAfterUpgradingNuget ([Values] AndroidRuntime runtime) } } + [Test] + [NonParallelizable] + public void SwitchingTypeMapImplementationTriggersClean () + { + var proj = new XamarinAndroidApplicationProject (); + proj.SetRuntime (AndroidRuntime.CoreCLR); + + using (var b = CreateApkBuilder ()) { + b.CleanupAfterSuccessfulBuild = b.CleanupOnDispose = false; + b.Verbosity = LoggerVerbosity.Detailed; + + var projectDir = Path.Combine (Root, b.ProjectDirectory); + if (Directory.Exists (projectDir)) + Directory.Delete (projectDir, true); + + // First build with default (llvm-ir) typemap + Assert.IsTrue (b.Build (proj), "first build should have succeeded."); + string build_props = b.Output.GetIntermediaryPath ("build.props"); + FileAssert.Exists (build_props, "build.props should exist after first build."); + var firstBuildProps = File.ReadAllText (build_props); + Assert.IsTrue (firstBuildProps.Contains ("_androidtypemapimplementation="), + "build.props should contain _AndroidTypeMapImplementation."); + + // Second build with trimmable typemap — should trigger clean + proj.SetProperty ("_AndroidTypeMapImplementation", "trimmable"); + b.Save (proj, doNotCleanupOnUpdate: true); + Assert.IsTrue (b.Build (proj), "second build (trimmable) should have succeeded."); + Assert.IsFalse (b.Output.IsTargetSkipped ("_CleanIntermediateIfNeeded"), + "Switching _AndroidTypeMapImplementation should trigger _CleanIntermediateIfNeeded."); + + // Third build switching back to llvm-ir — should trigger clean again + proj.SetProperty ("_AndroidTypeMapImplementation", "llvm-ir"); + b.Save (proj, doNotCleanupOnUpdate: true); + Assert.IsTrue (b.Build (proj), "third build (llvm-ir) should have succeeded."); + Assert.IsFalse (b.Output.IsTargetSkipped ("_CleanIntermediateIfNeeded"), + "Switching _AndroidTypeMapImplementation back should trigger _CleanIntermediateIfNeeded."); + + // Fourth build with no changes — should NOT trigger clean + Assert.IsTrue (b.Build (proj), "fourth build (no changes) should have succeeded."); + Assert.IsTrue (b.Output.IsTargetSkipped ("_CleanIntermediateIfNeeded"), + "A build with no implementation change should skip _CleanIntermediateIfNeeded."); + } + } + [Test] [Category ("SmokeTests")] public void BuildInDesignTimeMode ( diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index c2527d1954e..1a628b82b55 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -981,6 +981,7 @@ because xbuild doesn't support framework reference assemblies. <_PropertyCacheItems Include="AndroidManifestPlaceholders=$(AndroidManifestPlaceholders)" /> <_PropertyCacheItems Include="ProjectFullPath=$(MSBuildProjectFullPath)" /> <_PropertyCacheItems Include="AndroidUseDesignerAssembly=$(AndroidUseDesignerAssembly)" /> + <_PropertyCacheItems Include="_AndroidTypeMapImplementation=$(_AndroidTypeMapImplementation)" />