通过数据绑定创建和使用 AAR

Creating and using AAR's with databinding

目前我正在创建一些使用数据绑定的 android 模块,库模块在项目本身(作为项目依赖项)中运行良好。我遇到的问题是在另一个项目中使用那些 AAR 时(作为平面文件依赖项),它找不到一些符号(cannot find symbol variable R.id.some_id 有点问题)

这是我正在尝试使用的库模块的build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    dataBinding {
        enabled true
    }
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
}

然后我通过执行 gradle clean assembleRelease 创建 AAR,并将它放在 libs 文件夹中,然后我这样使用它:

//...
repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile (name:'librarymodule-release', ext:'aar')
}

我是不是漏掉了什么?还是无法在 AAR 中使用数据绑定?

我弄明白了,我在库项目中的布局文件与另一个同名文件冲突(它被称为 activity_main.xml,并且有另一个 activity_main.xml在我的宿主项目中)。

无论如何,感谢阅读。