【Android Studio】创建新项目遇到的一些问题

1.Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

这个问题的原因是我在使用

java 复制代码
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

出现的,表示项目正在使用已弃用的 Gradle 功能,这些功能与 Gradle 8.0 不兼容。当使用尚未更新以支持最新 Gradle 版本的旧库或插件时,很常见。

然后我们进入【Terminal】里面看看有啥问题

输入

java 复制代码
gradlew --warning-mode all

显示

最后发现是这个问题

java 复制代码
> Configure project :
The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's shutdown in February 2021. Use mavenCentral() instead. Consult the upgra
ding guide for further information: https://docs.gradle.org/7.0.2/userguide/upgrading_version_6.html#jcenter_deprecation
        at build_azgzdqjnd2tgvouqmjm5uilxd$_run_closure1$_closure2.doCall(D:\Android\AndroidProject\FormalProject\joy_wajueji\pad_wajueji\build.gradle:8)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

FAILURE: Build failed with an exception.

就是在这个里面

java 复制代码
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }

        google()
       jcenter()
    }

把那个 jcenter() 修改为 mavenCentral() 就好了。

然后看看还有什么问题

这里说明我们使用的Gradle版本很高,需要使用Java11,但是我们本地使用的是Java8,所以需要修改。

这样的话,要么我们替换成Java11,要么我们就降级Gradle版本就好了,要是降级gradle的话,可以这样使用

项目根目录下,找到 build.gradle 文件,并修改 classpath 中的 Android Gradle 插件版本。

java 复制代码
dependencies {
    classpath 'com.android.tools.build:gradle:4.1.3'  // 这是支持 Java 8 的版本
}

在 gradle-wrapper.properties 文件中,修改 distributionUrl 为较老的 Gradle 版本:

java 复制代码
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

这样就又可以愉快的使用Java8了。

相关推荐
BoomHe14 分钟前
Android LMK(Low Memory Killer)机制
android
JavaEdge.35 分钟前
IDEA卡死没反应的全部解决方案
java·ide·intellij-idea
时光呀时光慢慢走1 小时前
MAUI 开发安卓 MQTT 客户端:实现远程控制 (完整源码 + 避坑指南)
android·物联网·mqtt·c#
成都大菠萝1 小时前
2-2-44 快速掌握Kotlin-函数类型操作
android
有位神秘人2 小时前
Android中获取设备里面的音频文件
android
2501_915918412 小时前
使用 HBuilder 上架 iOS 应用时常见的问题与应对方式
android·ios·小程序·https·uni-app·iphone·webview
wanzhong23333 小时前
解决vscode在win下使用cuda无法跳转库函数的问题
ide·vscode·编辑器·cuda·高性能计算
farewell-Calm3 小时前
01_Android快速入门
android
helloCat3 小时前
记录CI/CD自动化上传AppGallery遇到的坑
android·前端·api
WordPress学习笔记4 小时前
wordpress根据页面别名获取该页面的链接
android·wordpress