Android Studio Bumblebee | 2021.1.1版本引入gradle plugin

子车才捷
2023-12-01

比如引入 'com.kezong.fat-aar'和 ‘hilt-android-gradle-plugin’

之前版本的使用

Module下的build.gradle

apply plugin: 'com.kezong.fat-aar'

工程目录下的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.kezong:fat-aar:1.3.8'
    }
}

--------------------------------------------------------------------------------

Android Studio Bumblebee | 2021.1.1之后的引入方式

Module下的build.gradle

plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'com.kezong.fat-aar'
}

 工程目录下的build.gradle如下

buildscript {
    ext.hiltVersion = "2.41"
    dependencies {
        classpath 'com.github.kezong:fat-aar:1.3.8'
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
    }
}

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

主要不同在于

buildscript {
    dependencies {
        classpath 'com.github.kezong:fat-aar:1.3.8'
    }
}

另外记录下代码仓库repositories的配置文件

修改到工程目录下的settings.gradle文件内

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()

        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven {
            url "https://jitpack.io"
        }
        maven {
            url "https://maven.google.com/"
        }
    }
}

 类似资料: