Android Studio Giraffe-2022.3.1-Patch-3安装注意事项

准备工作:

android studio下载地址:https://developer.android.google.cn/studio/releases?hl=zh-cn

gradle下载地址:https://services.gradle.org/distributions/

比较稳定的网络环境(比较android studio相关的依赖需要从谷歌那边下载的)

连接超时大部分是网络环境问题

一、环境

系统:Win11、jdk17

Android Studio Giraffe | 2022.3.1 Patch 3

gradle8.0

android studio安装省略,基本上是下一步下一步

需要注意:安装路径改成自己想安装的位置,如D盘

选择定制方式就可以选择自己想安装的位置




添加阿里云镜像:

创建 init.gradle 文件,gradle为文件格式

复制代码
allprojects {
    repositories { 
        mavenLocal() 
        maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" } 
        maven { name "Bstek" ; url "https://nexus.bsdn.org/content/groups/public/" } 
        mavenCentral()
    }
    buildscript {
        repositories { 
            maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' } 
            maven { name "Bstek" ; url 'https://nexus.bsdn.org/content/groups/public/' } 
            maven { name "M2" ; url 'https://plugins.gradle.org/m2/' }
        }
    }
}

不够还能继续添加:

复制代码
        maven {url = uri("https://maven.aliyun.com/repository/central")}  
        maven {url = uri("https://maven.aliyun.com/repository/public")}  
        maven {url = uri("https://maven.aliyun.com/repository/gradle-plugin")}  
        maven {url = uri("https://maven.aliyun.com/repository/google")}  
        maven {url = uri("https://jitpack.io")}  

二、配置

gradle配置:

Specified location对应地址:D:/Software/Android/gradle-repository/wrapper/dists/gradle-8.0-all/gradle-8.0

SDK位置:

gradle-wrapper.properties 配置:

三、遇到的问题

1.Android Gradle 插件和 Android Studio 兼容性

编译器版本:

复制代码
Android Studio Giraffe | 2022.3.1 Patch 3
Build #AI-223.8836.35.2231.11005911, built on October 26, 2023
Runtime version: 17.0.6+0-b2043.56-10027231 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1024M
Cores: 8
Registry:
    external.system.auto.import.disabled=true
    debugger.new.tool.window.layout=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.experimental.ui=true

Non-Bundled Plugins:
    Batch Scripts Support (1.0.13)
    CMD Support (1.0.5)

从版本信息中可以看到 android studio 2022.3.1需要对应的运行环境是JDK17

于是从官网文档中查看对应版的Gradle版本是3.2到8.1之间,我选择gradle plugin为7.4.2 、gradle版本是8.0

AGP指Android Gradle 插件 (AGP)

3.android系统版本对应的sdk版本

android API 升级

自 2023 年 8 月 31 日起,所有应用都**必须以 Android 12(API 级别 33)**或更高版本为目标平台,才能送交

Google Play 审核,否则可能无法被某些 Google Play 用户发现。将应用的目标 API 级别配置为新近的 API

级别可确保用户享受到安全性和性能方面的改进,同时应用仍然可以在较低版本的 Android(低至指定的

minSdkVersion)上运行。如需了解详情,请参阅 Google Play 的目标 API 级别要求。

编译器对应的支持的API级别上限

3. 控制台报错 A problem occurred configuring root project 'My Application3'.

复制代码
A problem occurred configuring root project 'My Application3'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:7.4.2.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:7.4.2
      > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')

Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8

不兼容,因为该组件声明了一个在编译时使用的组件,与 Java 11 兼容,而消费者需要一个在运行时使用的组件,与 Java 8 兼容

解决方法:使用JDK17即可解决

附件

参考:
Android Studio下载及安装和Gradle的配置

Android Studio Giraffe | 2022.3.1版本说明

Android studio汉化(2023最新版)

Android Studio.exe 下载 2023 最新更新,网盘下载

Android Studio 中最新的 Gradle 配置中设置插件依赖 ( 2023 年 8 月 24 日 | 最新 Gradle 中配置插件依赖的变化 | 增加 Maven 仓库源 )

相关推荐
Dovis(誓平步青云)1 小时前
家里设备越来越多,如何用一张空间地图控制灯光和温度![
android·java·前端·javascript·人工智能·电脑
晚风叙码3 小时前
MySQL 数据类型详解:从数值到字符串,一篇讲透
android·mysql·adb
传奇开心果编程3 小时前
【Compose Multiplatform 跨端开发学与练】第3课 布局与组件
android·windows·学习·ui·ios·kotlin·composer
传奇开心果编程6 小时前
【Compose Multiplatform 跨端开发学与练】第8课 资源管理与主题
android·windows·学习·ios·kotlin·web·composer
传奇开心果编程7 小时前
【Compose Multiplatform 跨端开发学与练】第9课 测试与调试
android·学习·macos·ios·kotlin·web·composer
传奇开心果编程8 小时前
【Compose Multiplatform 跨端开发学与练】第4课 导航与路由
android·windows·学习·ui·ios·kotlin·composer
传奇开心果编程8 小时前
【Compose Multiplatform 跨端开发学与练】第6课 状态管理与架构
android·学习·ui·ios·架构·kotlin·composer
事圆则缓8 小时前
Android AOSP 定制常见概念:源码目录、系统镜像与刷机流程
android
传奇开心果编程8 小时前
【Compose Multiplatform 跨端开发学与练】第2课 Compose 基础语法
android·windows·学习·ui·ios·kotlin·composer
supabc1238 小时前
Celium:连接 Windows、Mac、Linux 与 Android,让远程访问和设备管理更简单
android·linux·windows·macos·远程访问·网络管理·celium