我正在尝试使用奶油刀。但我得到了错误" 无法解决符号' ** ButterKnife '" 。 我试图手动导入butterknife.ButterKnife但我得到了同样的错误 我修改了gradle并添加了这些行: 在项目层面......
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
在模块级......
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
dependencies {
compile 'com.jakewharton:butterknife-compiler:8.5.1'
apt 'com.jakewharton:butterknife-compiler:8.5.1'
}
我该怎么办? 提前致谢 。 这是我的代码的截图,我得到了错误 link for the screenshot
答案 0 :(得分:1)
apply plugin: 'com.android.application'
android {
compileSdkVersion XX
buildToolsVersion "XX.0.0"
defaultConfig {
applicationId "com.xxxxx.xxx"
minSdkVersion xx
targetSdkVersion xx
versionCode x
versionName "x.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
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.1.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.android.support:design:25.1.1'
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
testCompile 'junit:junit:4.12'
}
答案 1 :(得分:0)
compile 'com.jakewharton:butterknife:7.0.1'
答案 2 :(得分:0)
试试这个,
compile 'com.jakewharton:butterknife:8.0.0'
apt 'com.jakewharton:butterknife-compiler:8.0.0'
答案 3 :(得分:0)
请检查official document here。 简而言之,您的依赖关系如下所示:
dependencies {
// ... other dependencies here
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
答案 4 :(得分:0)
试试这个,
apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.tanamo.tutorial"
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
答案 5 :(得分:0)
试试这个:
implementation 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'