Android Studio 5.3.3 新项目编译报错解决

文件 app/build.gradle.kts

json 复制代码
android {
    namespace = "com.example.myapplication"
    compileSdk {
        version = release(36) {
            minorApiLevel = 1
        }
    }

改为

json 复制代码
android {
    namespace = "com.example.myapplication"
    compileSdk = 36

文件gradle.properties

yaml 复制代码
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

# 末尾添加以下配置
# Suppress warning for unsupported compileSdk version
android.suppressUnsupportedCompileSdk=36
# Enable AndroidX
android.useAndroidX=true

文件 settings.gradle.kts

更改maven后如下

yaml 复制代码
pluginManagement {
    repositories {
        maven {
            url = java.net.URI.create("https://maven.aliyun.com/repository/google")
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        maven { url = java.net.URI.create("https://maven.aliyun.com/repository/central") }
        mavenCentral()
        maven { url = java.net.URI.create("https://maven.aliyun.com/repository/gradle-plugin") }
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven {
            url = java.net.URI.create("https://maven.aliyun.com/repository/google")
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        google()
        maven { url = java.net.URI.create("https://maven.aliyun.com/repository/central") }
        mavenCentral()
    }
}

rootProject.name = "onlyService001"
include(":app")

文件 gradle/libs.versions.toml

注意AGP版本

yaml 复制代码
[versions]
agp = "8.13.0"
# 以下省略

文件 gradle/gradle-wrapper.properties

设置gradle版本与agp版本对应

yaml 复制代码
#Wed Apr 08 12:24:02 CST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.13-bin.zip
#distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-9.3.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

在我的测试中 版本对应的测试结果如下

AGP gradle 结果
8.13.0 8.13.0 成功
8.13.0 9.3.1 失败
9.3.1 9.3.1 失败
相关推荐
程序员良辰36 分钟前
Eclipse Memory Analyzer(MAT)入门教程:从生成 Heap Dump 到定位 Java 内存问题
java·ide·eclipse·tomcat·idea
脚踏实地,坚持不懈!1 小时前
Android 系统工程师(性能/功耗/稳定性)岗位问题深度解析:从内核源码到实战排查(完善版)
android·linux·运维·服务器
pjj198541 小时前
Hadoop-python中使用大数据1
java·ide·eclipse
Kapaseker1 小时前
适配小米“中”折屏,非得买一台吗
android·kotlin
恋猫de小郭1 小时前
Flutter 状态管理基准测评,一个很有趣的观点
android·前端·flutter
可乐鸡翅yeah_1 小时前
App WebView 加载 M3U8 流媒体踩坑,安卓 iOS 混合开发播放异常定位
android·ios·harmonyos·m3u8·m3u8在线播放
木卫四科技1 小时前
从函数劫持到智能体控制平面:Hook 如何从 Linux-Android 演化到 Agent Runtime
android·linux·人工智能·安全
菠萝加点糖2 小时前
Android applicationIdSuffix 详解
android·gitee·kotlin
AIGC小尼2 小时前
穿山甲 + 腾讯短剧短视频聚合广告平台|Android+SpringBoot+Vue+Docker 完整部署指南
android·vue.js·spring boot·聚合广告·广告平台·穿山甲广告·腾讯广告
JMchen1234 小时前
【Android 性能优化实战 60 讲】06 GPU 呈现模式与卡顿视觉验证:拆解柱状图分层,秒辨渲染慢与等待慢
android·性能优化·实战·源码分析·渲染优化·gpu呈现模式·卡顿优化