build.gradle those things

1. Add Alibaba Cloud's resource mirroring to the build.gradle file in the root directory of the project

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.4.10"
    ext.jitpack_io = "https://jitpack.io"
    ext.ali_group = "http://maven.aliyun.com/nexus/content/groups/public/"
    ext.ali_jcenter = "http://maven.aliyun.com/nexus/content/repositories/jcenter"
    ext.ali_google = "http://maven.aliyun.com/nexus/content/repositories/google"
    ext.ali_gradle = "http://maven.aliyun.com/nexus/content/repositories/gradle-plugin"
    repositories {
        maven { url "$ali_group" }
        maven { url "$ali_jcenter" }
        maven { url "$ali_google" }
        maven { url "$ali_gradle" }
        maven { url "$jitpack_io" }
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "$ali_group" }
        maven { url "$ali_jcenter" }
        maven { url "$ali_google" }
        maven { url "$ali_gradle" }
        maven { url "$jitpack_io" }
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

2. The project on github introduced in the project depends on the use of the control when there is no prompt. Check whether the following code is added to the project root directory build.gradle file (the way to add can also refer to the above method):

repositories {
    // 确保已经添加,不然无法正常使用依赖
    maven { url "https://jitpack.io" }
}

3. The id defined in the xml cannot be directly referenced in the Activity page of the Kotlin project. Check whether "kotlin-android-extensions" is introduced under the plugin of the build.gradle file of the project's app

plugins {
    id 'kotlin-android-extensions'
}

Or the old version of the following method:

apply plugin: 'kotlin-android-extensions'

 

 

 

Guess you like

Origin blog.csdn.net/nsacer/article/details/109260651