kotlin 引用 anto库方法

首先在工程目录下的build.gradle里添加anto的版本,红色加粗标记那一行


buildscript {
    ext.kotlin_version = '1.1.2-4'
    ext.anko_version = '0.10.1'
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.+'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

//        compile "org.jetbrains.anko:anko-sdk25:$anko_version"
//        compile "org.jetbrains.anko:anko-sdk25-coroutines:$anko_version"
//        compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"

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

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        mavenCentral()
    }
}

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

2。再在app目录下的build.gradle中添加 
 
  
compile "org.jetbrains.anko:anko:$anko_version" ,来引用库


apply plugin: 'com.android.application'

apply plugin: 'kotlin-android“


    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    compile "org.jetbrains.anko:anko:$anko_version"

    //compile 'org.jetbrains.anko:anko:0.6.3-15'

    //    compile "org.jetbrains.anko:anko-sdk25:$anko_version"
//    compile "org.jetbrains.anko:anko-sdk25-coroutines:$anko_version"
//    compile "org.jetbrains.anko:anko-appcompat-v7:$anko_version"

//    compile("org.jetbrains.anko:anko:$anko_version") {
//        exclude group: 'com.google.android', module: 'android'
//    }


    testCompile 'junit:junit:4.12'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}

 


你可能感兴趣的:(android开发)