找不到ButterKnife编译器

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

我将ButterKnife集成到我的项目中,从那以后我就不可能构建它了

我尝试了不同版本的库,但似乎没有任何效果

这是构建过程中的错误:

Could not find com.jakewharton:butterknife-compiler:7.0.1.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.pom
  - https://dl.google.com/dl/android/maven2/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.jar
  - https://jcenter.bintray.com/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.pom
  - https://jcenter.bintray.com/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.jar
  - https://jitpack.io/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.pom
  - https://jitpack.io/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.jar
Required by:
    project :app

这是我的 build.gradle 文件:

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //Retrofit Dependencies
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'

    // Butter Knife
    implementation 'com.jakewharton:butterknife:7.0.1'
    implementation 'com.android.support:support-annotations:28.0.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:7.0.1'

    // ZXing
    implementation 'com.github.tobrun:QR-Vision-Fragment:master-SNAPSHOT'

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
}

我已经在项目 build.gradle 中添加了 jitpack 存储库:

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }

    }
}
android gradle butterknife
5个回答
2
投票

试试这个

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

2
投票

如果您正在构建旧的 Android 项目并且不想升级您的 Butterknife 依赖项,请将其添加到您的 gradle(应用程序级别)文件中。它对我有用。快乐编码:)

android {
   ...
  defaultConfig {
    javaCompileOptions {
      annotationProcessorOptions {
        includeCompileClasspath = true
      }
    }
  }
}

2
投票

使用这个:

compile 'com.jakewharton:butterknife:8.7.0'

annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'

2
投票

来自 this

butterknife-compiler
版本
7.0.1
未在 mvn 存储库中列出(创建)

所以使用最新的lib版本

implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

0
投票
 1. 
android {
  ...
  // Butterknife requires Java 8.
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  implementation 'com.jakewharton:butterknife:10.2.3'
  annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
}

 2. To use Butter Knife in a library, add the plugin to your buildscript:

buildscript {
  repositories {
    mavenCentral()
    google()
  }
  dependencies {
    classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.3'
  }
}

 3. and then apply it in your module:
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'

 4. Now make sure you use R2 instead of R inside all Butter Knife annotations.
class ExampleActivity extends Activity {
  @BindView(R2.id.user) EditText username;
  @BindView(R2.id.pass) EditText password;
...
}
© www.soinside.com 2019 - 2024. All rights reserved.