Changes in the dependency structure of the new version of Android Gradle 7.x

The dependency structure of the new Android Studio project of the Little Bee/Little Dolphin/Eel version has changed from the previous version, mainly including:

  1. The buildscript and allprojects in the project build.gradle were moved to setting.gradle and renamed to pluginManagement and dependencyResolutionManagement. The contents inside can still be copied according to the original.
pluginManagement {
    
    
    repositories {
    
    
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    
    
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
    
    
        google()
        mavenCentral()
    }
}
rootProject.name = "Jetpack"
include ':app'
  1. setting.gradle add rootProject.name = "Jetpack". If you modify this name, a new folder will be created under the current project name, and the original file will be moved to the new folder.
  2. The dependencies of the project's build.gradle are changed to plugins instead of referencing the original Gradle version.
plugins {
    
    
    id 'com.android.application' version '7.1.1' apply false
    id 'com.android.library' version '7.1.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false

If you want to use the old one, you can still add it in the project build.gradle in the original way without affecting the old method.

buildscript {
    
    
    dependencies {
    
    
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
    }
}

reference

https://developer.android.google.cn/studio/build/dependencies
https://blog.csdn.net/sinat_38167329/article/details/123175556

Guess you like

Origin blog.csdn.net/LucasXu01/article/details/126744091