2016-07-16 9 views
6

का उपयोग करके दृश्य इंजेक्ट करने में असमर्थ मैं अपनी परियोजना में बटरनाइफ का उपयोग करना चाहता हूं। जैसा कि Here वर्णित है मैंने इस तरह तितली की स्थापना की है।Butterknife 8.1.0

परियोजना स्तर मॉड्यूल में:

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 
    } 
} 

मॉड्यूल स्तर में

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' 

} 

अंदर गतिविधि

@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); 
} 

लेकिन जब मैं अपना आवेदन चलाता हूं तो मुझे यह निम्न त्रुटि संदेश मिलता है।

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>) 

क्या कोई मुझे बता सकता है कि मैं यहां क्या खो रहा हूं?

+0

कृपया अपनी परियोजना को साफ करने पर विचार करें और फिर – Eenvincible

+1

पुनर्निर्माण के लिए धन्यवाद, मैंने सुझाव दिया है कि मैंने सुझाव दिया था। लेकिन मुझे समाधान मिला है। मैं अपनी gradle फ़ाइल में दो अलग-अलग संस्करणों का उपयोग कर रहा था। कृपया मेरा जवाब देखें। @Eenvincible –

+0

मुझे खुशी है कि आपने इसे समझ लिया; खुश कोडिंग – Eenvincible

उत्तर

10

ठीक है यह मामूली गलती थी।

मैं gradle फ़ाइलों में विभिन्न संस्करणों का उपयोग कर रहा था।

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

अब जब मैंने संस्करण को सही तरीके से काम किया है। तो कुछ संस्करण संघर्ष वहाँ होगा।

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

इस जवाब ने मुझे बचाया जब मैंने सर्कल में घूमने के लिए कुछ घंटों बिताए। धन्यवाद। – jSherz

+0

मैंने चेंजलॉग से कंपाइलर आयात की प्रतिलिपि बनाई। इससे इस मुद्दे का कारण बन गया। धन्यवाद – joao2fast4u

+0

धन्यवाद, मैंने वही काम किया था। आपके उत्तर ने मुझे – xrnd

9

बस एक और इस मुद्दे पर सुझाव अपने Gradle फ़ाइल में जोड़ें। प्लगइन लागू होते हैं: 'android-उपयुक्त'

यह मैं बचाने के रूप में मैं इस मुद्दे के समान तरह सामना करना पड़ा। त्रुटि: (2 9, 0) तर्कों के लिए विधि apt() नहीं मिला [com.jakewharton: butterknife-compiler: 8.4.0] org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler के ऑब्जेक्ट पर।

+2

इसके लिए धन्यवाद! मैं एक और चीज रखना चाहता हूं। Classpath 'com.neenbedankt.gradle.plugins जोड़ने के लिए मत भूलना: android-apt: 1.8' आपके build.gradle में भी। –

संबंधित मुद्दे