【问题标题】:Creating and using AAR's with databinding通过数据绑定创建和使用 AAR
【发布时间】:2016-07-20 06:52:16
【问题描述】:

目前我正在创建一些使用数据绑定的 android 模块,库模块在项目本身内工作正常(作为项目依赖项)。我遇到的问题是在另一个项目中使用那些AAR 时(作为平面文件依赖项),它找不到一些符号(找不到符号变量 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')
}

我是否遗漏了什么?还是不能在AARs 中使用数据绑定?

【问题讨论】:

    标签: android android-studio data-binding aar android-databinding


    【解决方案1】:

    我已经弄清楚了,在我在库项目中的布局文件中,与另一个同名的文件冲突(它被称为activity_main.xml,在我的宿主项目中还有另一个activity_main.xml)。

    谢谢你的阅读。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多