ButterKnife迁移到AndroidX后未找到绑定

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

迁移到AndroidX后,我将ButterKnife更新到最新版本10.2.0

但是建造时,

我收到此错误

error: cannot find symbol class Bind

我尝试添加

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

但是它也没有帮助。

我看到一个答案,使minSdkVersion至少为15,在我的情况下已经为16。

这是我的build.gradle


android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'
    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 12
        versionName "2.2"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        incremental true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}


repositories {
    jcenter()
}


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.2.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'com.valdesekamdem.library:md-toast:0.9.0'
    implementation 'com.jakewharton:butterknife:10.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'

    implementation 'androidx.annotation:annotation:1.1.0'
    annotationProcessor 'androidx.annotation:annotation:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'

    implementation 'com.github.badoualy:stepper-indicator:1.0.7'

    testImplementation 'junit:junit:4.12'
}

android bind androidx butterknife
2个回答
0
投票
检查此link

repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots" } } dependencies { implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT' annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT' }


0
投票
@BindView(R.id.text_view) TextView mTextView;
成功。

我将@Bind修复为@BindView,它也成功。但是为什么他们要做出如此大的改变?因此,我不得不重做整个项目。

© www.soinside.com 2019 - 2024. All rights reserved.