2016-07-16 20 views
6

Tôi muốn sử dụng Butterknife trong dự án của mình. Như được mô tả Here Tôi đã thiết lập Butterknife như thế này.Không thể chuyển chế độ xem bằng Butterknife 8.1.0

Trong dự án mô-đun cấp:

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

Trong Mô-đun Cấp

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' 

} 

Bên Hoạt động

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

Nhưng khi tôi chạy ứng dụng của tôi, tôi nhận được thông báo lỗi sau.

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

Ai có thể cho tôi biết tôi đang thiếu gì ở đây?

+0

Hãy xem xét làm sạch dự án của bạn và sau đó xây dựng lại – Eenvincible

+1

Cảm ơn nhận xét tôi đã làm mà bạn đã đề xuất. Nhưng tôi đã tìm ra giải pháp. Tôi đã sử dụng hai phiên bản khác nhau trong tệp gradle của mình. xin có một cái nhìn một câu trả lời của tôi. @Eenvincible –

+0

Tôi rất vui vì bạn đã tìm ra; hạnh phúc mã hóa – Eenvincible

Trả lời

10

Ok Đó là lỗi nhỏ.

Tôi đang sử dụng các phiên bản khác nhau trong tệp gradle.

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

bây giờ khi tôi thay đổi phiên bản hoạt động bình thường. Vì vậy, một số xung đột phiên bản sẽ có mặt ở đó.

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

Câu trả lời này đã cứu tôi sau khi tôi đã dành một vài giờ tốt đi vòng trong vòng tròn. Cảm ơn. – jSherz

+0

Tôi đã sao chép nhập trình biên dịch từ các thay đổi. Điều đó gây ra vấn đề này. Cảm ơn – joao2fast4u

+0

Cảm ơn, tôi đã làm điều tương tự. câu trả lời của bạn đã giúp tôi – xrnd

9

Chỉ thêm một đề xuất về vấn đề này thêm vào tệp gradle của bạn. áp dụng plugin: 'android-apt'

này tiết kiệm cho tôi khi tôi phải đối mặt với loại vấn đề tương tự. Lỗi: (29, 0) Không thể tìm thấy phương thức apt() cho đối số [com.jakewharton: butterknife-compiler: 8.4.0] trên đối tượng thuộc loại org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

+2

Cảm ơn vì điều đó! Tôi muốn đặt thêm một điều nữa. Đừng quên thêm classpath 'com.neenbedankt.gradle.plugins: android-apt: 1.8' trong build.gradle của bạn. –

Các vấn đề liên quan