내 안드로이드 프로젝트에서 dagger2 및 Butterknife를 사용하는 방법을 배우고 Butterknife BindView 주석을 삽입 할 때까지 모든 것이 잘 작동합니다.Android Dagger2 및 Butterknife 충돌
오류 : (5, 57) 오류 : 기호 클래스 DaggerNetComponent
을 찾을 수없는 것은이 내 DaggerNetComponent 코드 :
public class App extends Application {
private NetComponent mNetComponent;
@Override
public void onCreate() {
super.onCreate();
mNetComponent = DaggerNetComponent.builder().appModule(new AppModule(this)).netModule(new NetModule("http://example.com/"))
.build();
}
public NetComponent getNetComponent()
{
return mNetComponent;
}
}
이 내가 butterknife와 함께 내 시야를 주입하는 방법이다 :
public class MainActivity extends AppCompatActivity implements MainScreenContact.View {
@BindView(R.id.listContact)
ListView listView;
ArrayList<CharSequence> list;
ArrayAdapter<CharSequence> adapter;
@Inject
MainScreenPresenter mainPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
BindView 주석을 제거하면 이 클래스에 terKnife를 바인딩하면 잘 작동하지만 사용하면 오류가 표시됩니다.
이 내 Gradle.app입니다
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.project.echo.contactmanagement"
minSdkVersion 14
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'
}
}
}
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.0.0'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.0.2'
//OkHttp
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okio:okio:1.7.0'
//Gson
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.1'
//RxJava
compile 'io.reactivex:rxjava:1.1.2'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.1'
testCompile 'junit:junit:4.12'
//Dagger
apt 'com.google.dagger:dagger-compiler:2.2'
compile 'com.google.dagger:dagger:2.2'
provided 'javax.annotation:jsr250-api:1.0'
//butterknife
compile 'com.jakewharton:butterknife:8.1.0'
apt 'com.jakewharton:butterknife-compiler:8.1.0'
}
제발 도와주세요, 어떤 대답은
이apt
범위를 사용하는 경우
이
ButterKnife 주석 처리가 실패하면 단검도 실패 할 수 있습니다. 'R.id.listContact'가'ListView '의 인스턴스를 가리키고 있는지 확인하고 청소와 재구성을 시도하십시오. 또한 다른 컴파일 타임 오류도 확인하십시오. –
내 ButterKnife 주석은 실패하지 않으며 R.id.listContact는 ListView를 가리 킵니다. 코드를 삭제하고 다시 작성하려고했지만 오류가 계속 표시됩니다. ButterKnife 주석을 제거하면 오류가 사라집니다. – user1290932
Dagger 2의 최신 버전과 ButterKnife의 최신 버전을 갖고 있습니까? 최소한 build.gradle을 포함하도록 게시물을 수정하십시오. 더 좋은 점은 문제를 재현하는 최소 프로젝트를 만드는 것입니다. 우리는이 두 가지 라이브러리를 프로젝트에서 함께 사용하고 있습니다. –