Realm.io/Dagger/Databinding在同一个项目中

Dar*_*ian 5 android realm dagger-2 android-databinding

在通过gradle添加Realm.io作为依赖项后,我遇到了编译项目的问题.无法找到由dagger和数据绑定创建的生成文件.如果我删除realm.io应用程序正确编译.

这是我的build.gradle

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

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    multiDexEnabled true
    applicationId "com.foo"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.facebook.stetho:stetho:1.2.0'
compile 'com.facebook.stetho:stetho-okhttp:1.2.0'
compile 'io.reactivex:rxandroid:0.24.0'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okio:okio:1.4.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:design:23.1.0'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'io.realm:realm-android:0.85.1'

compile 'com.google.dagger:dagger:2.0.1'
provided 'javax.annotation:jsr250-api:1.0'
apt "com.google.dagger:dagger-compiler:2.0.1"
apt 'com.android.databinding:compiler:1.0-rc4'
}
Run Code Online (Sandbox Code Playgroud)

错误

我看到Realm也在生成文件,也许编译器不能很好地协同工作.关于如何使这个工作的任何想法?

谢谢

小智 1

Realm、Dagger2 和数据绑定都在我的项目中工作。

区别在于:

我正在使用 android gradle 插件 1.5.0 并通过以下配置启用数据绑定。

android {
    ...
    dataBinding {
        enabled = true
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

而我没有

apt 'com.android.databinding:compiler:1.0-rc4'
Run Code Online (Sandbox Code Playgroud)

在依赖关系中。

整个工作项目在这里: https: //github.com/zaki50/realm_template