databinding 与 dagger2冲突问题

发布于 2022-09-04 19:19:34 字数 2815 浏览 16 评论 0

databinding 与 dagger2同时使用,会出现databinding类不存在错误,单独使用databinding把apt注释掉,可以编译运行, 请问下这个问题应该如何解决,我想在新项目中同时使用这两个库,但是根据网上的教程,还是会存在冲突

以下是配置文件代码

project:

buildscript {

repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'

    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
}

}

allprojects {

repositories {
    jcenter()
}

}

task clean(type: Delete) {

delete rootProject.buildDir

}

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

android {

compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
    applicationId "com.shen.mzv"
    minSdkVersion 15
    targetSdkVersion 25
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    versionCode 49
    versionName '1.1.1'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

//
// compileOptions {
// targetCompatibility 1.8
// sourceCompatibility 1.8
// }

dataBinding {
    enabled = true
}

}

dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.lovedise:permissiongen:0.0.6'
compile 'io.reactivex.rxjava2:rxjava:2.0.2'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
compile 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'
//dagger2
compile 'com.google.dagger:dagger:2.9'
//
provided 'com.google.dagger:dagger-compiler:2.9'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
//Retrofit2所需要的包
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
//ConverterFactory的Gson依赖包
compile 'com.squareup.retrofit2:converter-scalars:2.2.0'
//ConverterFactory的String依赖包
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
//    compile "com.google.code.gson:gson:2.8.0"
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春风十里 2022-09-11 19:19:34

已经解决
先把android-apt注释掉
使用 annotationProcessor 'com.google.dagger:dagger-compiler:2.x' 代替 apt 'com.google.dagger:dagger-compiler:2.x'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文