kotlin项目引用

概要:

记录项目引用kotlin具体事项

1 object下build.gradle

复制代码
buildscript {
    //声明引用版本
    ext.kotlin_version = "1.4.20"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.0"
        //引用kotlin
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

2 APP下build.gradle

复制代码
plugins {
    id 'com.android.application'
    //声明引用kotlin插件
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.1'

    defaultConfig {
        applicationId "com.ljt.retrofitobject_xiaoma"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    //引用kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
}
相关推荐
眠りたいです8 分钟前
现代C++:C++11并发支持库
开发语言·c++·多线程·c++11·c++并发支持库
小灰灰搞电子14 分钟前
Rust可以取代C++么?
开发语言·c++·rust
保持低旋律节奏16 分钟前
linux——进程状态
android·linux·php
cat三三19 分钟前
java之异常
java·开发语言
奇树谦21 分钟前
【Qt实战】实现图片缩放、平移与像素级查看功能
开发语言·qt
我命由我1234528 分钟前
Python Flask 开发问题:ImportError: cannot import name ‘Markup‘ from ‘flask‘
开发语言·后端·python·学习·flask·学习方法·python3.11
wjs202430 分钟前
Go 语言指针
开发语言
明川32 分钟前
Android Gradle - ASM + AsmClassVisitorFactory插桩使用
android·前端·gradle
wuguan_42 分钟前
C#:多态函数重载、态符号重载、抽象、虚方法
开发语言·c#