…dotnet#33727)
AGP 8.11.1 auto-selects build-tools 35.0.0 for compileSdk 35, which
isn't commonly installed. This causes build failures in the Android
native module.
## Changes
- **src/Core/AndroidNative/maui/build.gradle**
- Bump `compileSdk` from 35 to 36
- Add explicit `buildToolsVersion "36.0.0"` to override AGP's
auto-selection
- Bump `targetSdk` from 35 to 36
- **src/Core/AndroidNative/build.gradle**
- Replace deprecated `buildDir` with `layout.buildDirectory` (Gradle 8+
API)
- **eng/Versions.props**
- Remove `IsDefault="True"` from API 35 (only API 36 is default now)
- Remove `AndroidSdkBuildToolsVersion` property (no longer needed)
- **eng/pipelines/common/ui-tests-build-sample.yml**
- Remove outdated FIXME comment about API 35
- **src/Provisioning/Provisioning.csproj**
- Remove build-tools provisioning line (gradle file now explicitly
specifies version)
```gradle
android {
compileSdk 36
buildToolsVersion "36.0.0" // Override AGP auto-selection
namespace "microsoft.maui"
defaultConfig {
minSdk 21
targetSdk 36
...
}
}
```
Explicit buildToolsVersion takes precedence over AGP inference, ensuring
builds use an available version.
The `AndroidSdkBuildToolsVersion` MSBuild property has been removed as
it's no longer necessary - the gradle file now directly manages the
build-tools version. Build-tools can be installed through Android SDK
Manager or other standard Android development tools as needed.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
Create a PR with these changes. They should be good to go and need no
further updates
<analysis>
**Chronological Review:**
1. Initial phase: User requested checkout of DecorView-Fix PR branch,
rebase to main, and create test sample
2. First build attempt: BuildTasks failed with build-tools 35.0.0 not
found error
3. Investigation phase: Determined AGP 8.11.1 tries to use build-tools
35.0.0 for compileSdk 35
4. First fix attempt: Changed compileSdk to 36, still failed until
explicit buildToolsVersion added
5. Exploration phase: User asked to test AGP 9.x upgrade on new branch
6. AGP upgrade failure: Microsoft.Android.Sdk.Windows 36.1.12
incompatible with Gradle 9.x due to Kotlin type safety
7. Documentation phase: Created detailed bug reports for Microsoft
Android SDK team
8. Final resolution: User decided on minimal build-tools fix approach
9. Branch creation: Created fix-android-build-tools-36 with surgical
changes
10. Cleanup phase: Verified changes, removed untracked files from
previous experiments
**Intent Mapping:**
- Message 1: "checkout the following branch...rebase it to main, write a
sample on the sandbox project" - Test DecorView-Fix PR
- Message 2: "can you build the BuildTasks please" - Compile BuildTasks
solution
- Message 3: "just build it with debug please and then open the
-windows.slnf in VS" - Build configuration clarification
- [6 messages omitted in context]
- "why do you like that better than option 2?" - Comparing fix
approaches
- "yes, please make that change and then lets see if it compiles" -
Approve specific fix
- "did we need to set buildToolsVersion or does just setting compileSdk
do enough?" - Understanding fix necessity
- "delete the artifacts folder before testing again" - Clean build
verification
- "why is buildtoolsversion needed now but never was before? please
figure it out" - Root cause analysis
- "so why doesn't bumping compileSdk to 36 cause it to try and use
build-tools 36?" - Understanding AGP behavior
- "what is AGP and should we bump AGP?" - Context on Android Gradle
Plugin
- "switch to the main branch, checkout a new branch, bump AGP and
compileSDK and see if things build" - Test AGP upgrade path
- "is agp 9.0 a good version to bump to? or should we try even higher?"
- Version selection guidance
- "are you sure it requires breaking changes? can you work on fixing our
code so that AGP 9.2.0 works" - Challenge incompatibility claim
- "are you positive about this? are you just blaming MSFT for your own
inability to make this work?" - Verify technical accuracy
- "can you summarize why you think it's not compatible" - Consolidate
reasoning
- "is there anything official you can find to indicate that
Microsoft.Android.Sdk.Windows 36.1.12 doesn't support gradle 9" -
Request documentation
- "can you give me specific errors I can show someone from that team?" -
Prepare bug report
- "alright lets go with the build tools and compilesdk fix for now, can
you create a new branch with those changes and make sure we are sync
with origin main" - Final decision on approach
- "sorry keep going" - Continue after interruption
- "what are all the changes made? is there anything lingering or are
these all the changes you made for build tools?" - Verify clean state
- "yes please clean the untracked files we only want changes around
updating gradle bits here" - Final cleanup request
**Technical Inventory:**
- .NET 10.0.100 (net10.0)
- Microsoft.Android.Sdk.Windows 36.1.12
- Android Gradle Plugin (AGP) 8.11.1 (current stable)
- Gradle 8.13
- Android compileSdk/targetSdk levels (35 vs 36)
- Android build-tools (33.0.0, 36.0.0 installed; 35.0.0 not installed)
- Kotlin type safety in Gradle 9.x
- MSBuild target system
- Git workflow (branches, rebasing, cherry-picking)
- DecorView-Fix PR: SafeArea padding handling for AdjustResize mode
**Code Archaeology:**
- src/Core/AndroidNative/maui/build.gradle: Gradle configuration for
MAUI Android native library (compileSdk, targetSdk, buildToolsVersion)
- src/Core/AndroidNative/build.gradle: Top-level Gradle config (clean
task with buildDir → layout.buildDirectory)
- src/Core/AndroidNative/gradle/wrapper/gradle-wrapper.properties:
Gradle version definition (8.13)
- eng/Versions.props: MSBuild version properties
(AndroidSdkBuildToolsVersion)
-
artifacts/obj/Core/Debug/net10.0-android36.0/gradle/net.android.init.gradle.kts:
Generated Kotlin file causing AGP 9.x failures
- src/Controls/samples/Controls.Sample.Sandbox/: Test files created for
DecorView-Fix testing
- KeyboardTestPage.xaml/.cs: Test page with multiple Entry fields
- MainActivity.cs: Modified for AdjustResize mode
- App.xaml.cs: Modified for Shell with bottom tabs
**Progress Assessment:**
Completed:
- ✅ DecorView-Fix PR analyzed and rebased to main
- ✅ Sandbox test sample created (on separate branch)
- ✅ Root cause identified: AGP tries to use build-tools 35.0.0 for
compileSdk 35
- ✅ AGP 9.x upgrade tested and determined incompatible with current SDK
- ✅ Bug reports created for Microsof...
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
Created from Copilot CLI via the copilot delegate command.
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: Shane Neuville (HE/HIM) <shneuvil@microsoft.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Co-authored-by: PureWeen <5375137+PureWeen@users.noreply.github.com>
Co-authored-by: Shane Neuville <shane94@hotmail.com>
AGP 8.11.1 auto-selects build-tools 35.0.0 for compileSdk 35, which isn't commonly installed. This causes build failures in the Android native module.
Changes
src/Core/AndroidNative/maui/build.gradle
compileSdkfrom 35 to 36buildToolsVersion "36.0.0"to override AGP's auto-selectiontargetSdkfrom 35 to 36src/Core/AndroidNative/build.gradle
buildDirwithlayout.buildDirectory(Gradle 8+ API)eng/Versions.props
IsDefault="True"from API 35 (only API 36 is default now)AndroidSdkBuildToolsVersionproperty (no longer needed)eng/pipelines/common/ui-tests-build-sample.yml
src/Provisioning/Provisioning.csproj
Explicit buildToolsVersion takes precedence over AGP inference, ensuring builds use an available version.
The
AndroidSdkBuildToolsVersionMSBuild property has been removed as it's no longer necessary - the gradle file now directly manages the build-tools version. Build-tools can be installed through Android SDK Manager or other standard Android development tools as needed.Original prompt
Create a PR with these changes. They should be good to go and need no further updates
**Chronological Review:** 1. Initial phase: User requested checkout of DecorView-Fix PR branch, rebase to main, and create test sample 2. First build attempt: BuildTasks failed with build-tools 35.0.0 not found error 3. Investigation phase: Determined AGP 8.11.1 tries to use build-tools 35.0.0 for compileSdk 35 4. First fix attempt: Changed compileSdk to 36, still failed until explicit buildToolsVersion added 5. Exploration phase: User asked to test AGP 9.x upgrade on new branch 6. AGP upgrade failure: Microsoft.Android.Sdk.Windows 36.1.12 incompatible with Gradle 9.x due to Kotlin type safety 7. Documentation phase: Created detailed bug reports for Microsoft Android SDK team 8. Final resolution: User decided on minimal build-tools fix approach 9. Branch creation: Created fix-android-build-tools-36 with surgical changes 10. Cleanup phase: Verified changes, removed untracked files from previous experimentsIntent Mapping:
Technical Inventory:
Code Archaeology:
Progress Assessment:
Completed:
Created from Copilot CLI via the copilot delegate command.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.