领域和奶油刀一起使用然后奶油刀不起作用

问题描述 投票:0回答:1

这是我的项目级build.gradle的一部分:

buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
        classpath "io.realm:realm-gradle-plugin:4.3.3"

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

应用程序级build.gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'realm-android'

android {
    compileSdkVersion 25
    defaultConfig {
        applicationId "com.reader.hanli.reader"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

realm {
    syncEnabled = true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:' + rootProject.supportVersion
    implementation 'com.android.support:design:' + rootProject.supportVersion
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}

在我添加领域之前,butterknife很好。而且我没有收到任何由butterknife抛出的例外,只是一个

空指针异常

在视图上。那么问题是什么?有没有人遇到过这样的问题?

realm butterknife
1个回答
0
投票

你正在使用Kotlin,所以你应该有

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt' // <-- !!!!
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'realm-android'

kapt 'com.jakewharton:butterknife-compiler:8.4.0'
© www.soinside.com 2019 - 2024. All rights reserved.