2016-07-16 12 views
6

Chcę używać urządzenia Butterknife w moim projekcie. Jak opisano w artykule Here, tak utworzyłem ten nożyk.Nie można wyświetlić widoku przy użyciu urządzenia Butterknife 8.1.0

W module poziomie projektu:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.0.0' 
     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 
     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

moduł Poziomu

apply plugin: 'com.android.application' 
apply plugin: 'android-apt' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.id.myprojectid" 
     minSdkVersion 11 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    useLibrary 'org.apache.http.legacy' 
} 


dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'com.android.support:design:23.3.0' 
    compile files('libs/libphonenumber-7.0.4.jar') 
    compile files('libs/universal-image-loader-1.9.5.jar') 
    compile files('libs/httpmime-4.1.jar') 
    compile 'com.google.android.gms:play-services:8.4.0' 
    compile 'com.android.support:recyclerview-v7:23.1.1' 
    compile 'com.google.android.gms:play-services-analytics:7.3.0' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.jakewharton:butterknife:8.2.1' 
    apt 'com.jakewharton:butterknife-compiler:8.0.1' 
    compile 'com.mcxiaoke.volley:library:1.0.19' 

} 

Wewnątrz Aktywny

@BindView(R.id.et_password) EditText et_password; 
    @BindView(R.id.et_fullname) EditText etFullname; 
    @BindView(R.id.et_email) EditText etEmail; 
    @BindView(R.id.et_contact) EditText et_contact; 
    @BindView(R.id.et_refer) EditText et_referId; 
    @BindView(R.id.cbPasswordVisible) CheckBox checkBox; 


protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_signup); 
     ButterKnife.bind(this); 
} 

Ale po uruchomieniu aplikacji otrzymuję następujący komunikat o błędzie.

Error:(20, 32) error: method castView in enum Finder cannot be applied to given types; 
required: View,int,String,Class<T> 
found: View,int,String 
reason: cannot instantiate from arguments because actual and formal argument lists differ in length 
where T is a type-variable: 
T extends Object declared in method <T>castView(View,int,String,Class<T>) 
Error:(22, 31) error: method castView in enum Finder cannot be applied to given types; 
required: View,int,String,Class<T> 
found: View,int,String 
reason: cannot instantiate from arguments because actual and formal argument lists differ in length 
where T is a type-variable: 
T extends Object declared in method <T>castView(View,int,String,Class<T>) 

Czy ktoś może mi powiedzieć, czego tu brakuje?

+0

Proszę rozważyć wyczyszczenie projektu, a następnie odbudować – Eenvincible

+1

Dzięki za komentarz zrobiłem to, co zasugerowałeś. Ale znalazłem rozwiązanie. W moim pliku gradle używałem dwóch różnych wersji. pls spojrzeć na moją odpowiedź. @ Eugencible –

+0

Cieszę się, że to wymyśliłeś; szczęśliwe kodowanie – Eenvincible

Odpowiedz

10

OK To był drobny błąd.

Używam różnych wersji w plikach gradle.

compile 'com.jakewharton:butterknife:8.2.1' 
apt 'com.jakewharton:butterknife-compiler:8.0.1' 

teraz, gdy zmieniłem wersję działa poprawnie. Więc istnieje konflikt między wersjami.

compile 'com.jakewharton:butterknife:8.2.1' 
    apt 'com.jakewharton:butterknife-compiler:8.2.1' 
+0

Ta odpowiedź uratowała mnie po tym, jak spędziłem kilka dobrych godzin w kółko. Dzięki. – jSherz

+0

Skopiowałem import kompilatora z dziennika zmian. To spowodowało ten problem. Dzięki – joao2fast4u

+0

Dzięki, zrobiłem to samo. Twoja odpowiedź pomogła mi – xrnd

9

tylko jedna sugestie dotyczące tej kwestii dodać w pliku Gradle. zastosowanie wtyczki: 'android-apt'

to zaoszczędzić mi jako że w obliczu podobnego rodzaju kwestii. Błąd: (29, 0) Nie można znaleźć metody apt() dla argumentów [com.jakewharton: butterknife-compiler: 8.4.0] na obiekcie typu org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

+2

Dzięki za to! Chciałbym dodać jeszcze jedną rzecz. Nie zapomnij dodać ścieżki klasy "com.neenbedankt.gradle.plugins: android-apt: 1.8" również w swoim build.gradle. –

Powiązane problemy