任务'app:copyDebugAndroidTestKotlinClasses'的执行失败 - Android Kotlin Build Error

时间:2017-04-08 18:44:13

标签: android gradle build android-gradle kotlin

我正在尝试使用Kotlin构建一个两个模块项目,我遇到了这个构建错误,但我不确定如何解决它。

Error:Execution failed for task ':app:copyDebugAndroidTestKotlinClasses'.
> kotlin.KotlinNullPointerException (no error message)

我的项目build.gradle如下:

buildscript {
    ext.compileSdkVersion = 25
    ext.buildToolsVersion = "25.0.2"
    ext.minSdkVersion = 16
    ext.targetSdkVersion = 25

    ext.kotlin_version = '1.1.0'
    ext.supportLibVersion = '25.3.1'

    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        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
    }
}

apply plugin: "kotlin"

allprojects {
    repositories {
        jcenter()

        maven {
            url "https://jitpack.io"
        }
    }
}

我的app模块build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

ext.jUnitVersion = '4.12'
ext.espressoVersion = '2.2.2'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.thinkbubble.app"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

kapt {
    generateStubs = true
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(path: ':bubblepicker')

    compile "com.android.support:appcompat-v7:$supportLibVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    testCompile "junit:junit:$jUnitVersion"
    androidTestCompile("com.android.support.test.espresso:espresso-core:$espressoVersion", {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}

我的第二个模块的build.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion rootProject.compileSdkVersion
    buildToolsVersion rootProject.buildToolsVersion

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:$supportLibVersion"
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    compile files('libs/jbox2d-library-2.1.2.2.jar')
    compile files('libs/slf4j-api-1.7.22.jar')

    compile 'io.reactivex:rxkotlin:0.60.0'
    compile 'io.reactivex:rxandroid:1.2.0'
    compile 'io.reactivex:rxjava:1.1.6'
}
repositories {
    mavenCentral()
}

可能导致出现此异常的原因是什么?

0 个答案:

没有答案