2017-05-20 33 views
14

Chỉ cần nâng cấp lên Android Studio 3.0, một dự án được soạn thảo trước khi được ném sau lỗiAndroid Studio 3.0 Canary 1 chú thích bộ xử lý lỗi

Error:java.lang.RuntimeException: Annotation processors must now be declared explicitly. The following dependencies in the compile classpath are found to contain annotation processors. Please add them to the annotationProcessor configuration.

Tuy nhiên, following này không được định nghĩa. đây là cách lập báo cáo trong build.gradle của tôi trông giống như

compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
    transitive = true; 
} 

compile 'com.android.support:support-v4:25.3.1' 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:design:25.3.1' 
compile 'com.squareup.retrofit2:retrofit:2.1.0' 
compile 'com.squareup.retrofit2:converter-gson:2.1.0' 
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' 
compile 'com.jakewharton.timber:timber:4.4.0' 
compile 'io.reactivex:rxandroid:1.0.1' 
compile 'io.reactivex:rxjava:1.0.14' 
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' 
compile 'com.jpardogo.googleprogressbar:library:1.2.0' 
compile 'com.wang.avi:library:2.1.3' 
compile 'link.fls:swipestack:0.3.0' 
compile 'com.jakewharton:butterknife:8.4.0' 
compile 'com.codemybrainsout.rating:ratingdialog:1.0.7' 
compile 'org.greenrobot:greendao:3.2.0' 
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' 
testCompile 'junit:junit:4.12' 
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' 
provided 'org.projectlombok:lombok:1.12.6' 

Trả lời

18

Hóa ra LombokButterknife vấn đề đã gây ra

tôi cập nhật ButterKnife và thêm annotationProcessor cho Lombok mà giải quyết vấn đề này

implementation 'com.jakewharton:butterknife:8.6.0' 
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' 

compileOnly 'org.glassfish:javax.annotation:10.0-b28' 
compileOnly "org.projectlombok:lombok:1.16.16" 
annotationProcessor "org.projectlombok:lombok:1.16.16" 

Cập nhật

Theo @ Beshoy's nhận xét bên dưới đã thay đổi compile thành implementationprovided tới compileOnly

+1

Bạn cũng nên cập nhật cấu hình phụ thuộc của bạn. 'compile' và' provided' hiện không được chấp nhận, sử dụng 'implementation' và' compileOnly'. https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations –

+0

Thực sự quan trọng 'compileOnly' cho lombok. Nó không làm việc cho tôi chỉ với 'biên dịch' – galaxigirl

11

xem thông báo lỗi sau khi biên dịch. nó sẽ hiển thị tên gói cần quá trình chú thích. ví dụ:

Error:Execution failed for task ':MPChart_libary:javaPreCompileDebug'. 
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. 
    - realm-android-0.87.5.jar 
    Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. 
    See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details. 

tên tìm kiếm "vương quốc-android-0.87.5" trong tập tin build.gradle của Module "MPChart_libary":

dependencies { 
    provided 'io.realm:realm-android:0.87.5' 
} 

sửa chữa tập tin build.gradle như sau:

dependencies { 
    provided 'io.realm:realm-android:0.87.5' 
    annotationProcessor 'io.realm:realm-android:0.87.5' //fix here 
} 
1

Tôi có cùng sự cố với thư viện MPchart, trong build.gradle của dự án MPchart thêm điều này:

defaultConfig { 
     ... 
     javaCompileOptions { 
      annotationProcessorOptions { 
       includeCompileClasspath true 
      } 
     } 
    } 
0

1- Vô hiệu hóa các lỗi xử lý chú thích kiểm tra

Nếu bạn có phụ thuộc vào classpath biên dịch bao gồm bộ vi xử lý chú thích bạn không cần, bạn có thể vô hiệu hóa việc kiểm tra lỗi bằng cách thêm dòng sau vào build.gradle của bạn tập tin. Hãy ghi nhớ, các bộ xử lý chú thích mà bạn thêm vào đường dẫn lớp biên dịch vẫn chưa được thêm vào đường dẫn lớp vi xử lý.

android { 
    ... //others options 
    defaultConfig { 
    ... 
    javaCompileOptions { 
     annotationProcessorOptions { 
      includeCompileClasspath false 
     } 
     } 
    } 
} 
1
  1. mở build.gradle của dự án
  2. Chỉ cần thêm những dòng trong defaultConfig:

    javaCompileOptions { 
           annotationProcessorOptions { 
             includeCompileClasspath true 
            } 
          } 
    
Các vấn đề liên quan