You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Android Studio新项目默认SDK及BuildTools版本至27?

Hey there! Let me break down two solutions for you—one that modifies the template path you found, and a far better, sustainable global setting that avoids having to tweak templates every time Studio updates.

1. Modifying the Default Template File (Your Found Path)

Since you already located the template folder at C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle-projects\NewAndroidModule\root, here's exactly what to edit:

  • Look for the file named build.gradle.ftl (it’s a FreeMarker template that generates your project’s build.gradle file)
  • Open it with a text editor (you’ll likely need admin permissions to save changes—copy the file to your desktop first, edit, then replace it back if you hit permission roadblocks)
  • Find the lines defining compileSdkVersion and targetSdkVersion—change their values from 26 to 27
  • If buildToolsVersion isn’t already present, add it under the compileSdk line like this:
    buildToolsVersion "27.0.3"
    
  • Save the file, and next time you create a project, it’ll use your desired versions automatically.

Heads up: This change will get overwritten if you update Android Studio, so it’s a temporary fix at best.

2. Global Default SDK Settings (The Optimal Approach)

This method sets default values for all new projects, and won’t be wiped by Studio updates. Here’s how to do it:

  • Open Android Studio, go to File > New Projects Setup > Structure for New Projects (this menu is dedicated to configuring defaults for every new project you create)
  • In the left sidebar, select Project:
    • Set Project SDK to Android 27 (make sure you’ve already downloaded this SDK via the SDK Manager first)
  • Next, go to Modules > Default Config in the left sidebar:
    • Set Compile Sdk Version to 27
    • Set Target Sdk Version to 27
  • To lock in the buildToolsVersion globally, open your user-level gradle.properties file at C:\Users\[Your Username]\.gradle\gradle.properties and add this line:
    android.buildToolsVersion=27.0.3
    
  • Save all settings, and from now on every new project will automatically use SDK 27 and buildTools 27.0.3 without any manual edits.

Pro tip: Before setting this up, double-check that you’ve installed Android 27 SDK Platform and Build Tools 27.0.3 via File > Settings > Appearance & Behavior > System Settings > Android SDK.

内容的提问来源于stack exchange,提问作者Damn Vegetables

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:03:27