我尝试使用 Dagger 2,但出现错误。在下面添加代码对我没有帮助。
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500" // or whatever number you want
}
}
我的 build.gradle (:app) 看起来像
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
...
dependencies {
compile 'com.google.dagger:dagger:2.23.2'
compile 'com.google.dagger:dagger-android:2.23.2'
compile 'com.google.dagger:dagger-android-support:2.23.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.23.2'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.23.2'
compile 'me.tatarka.bindingcollectionadapter:bindingcollectionadapter:1.3.0'
}
我使用 compileSdkVersion 设置为 26,Gradle Wrapper 设置为 3.5,Android Gradle Build Tools 设置为 2.2.3。
错误:
C:\Projects\xxx\app\src\main\java\pl\xxx\view\activity\MainActivity.java:31: error: package pl.xxx.databinding does not exist
import pl.xxx.databinding.ActivityMainBinding;
^
C:\Projects\xxx\app\src\main\java\pl\upos\xxx\view\activity\MainActivity.java:52: error: cannot find symbol
private ActivityMainBinding binding;
^
symbol: class ActivityMainBinding
location: class MainActivity