我有一个应用程序模块和一个作为库使用的模块--我仍然在对库进行更改,所以它不是预编译的。库模块有自己的res文件夹,我想将其与主应用程序的res文件夹分开。我认为唯一能做到这一点的方法是将库打包成一个aar,然后将它包含在主应用程序中。如果我可以运行一个Gradle构建来打包这个库并包含它,那将是很方便的。这个是可能的吗?
gradle.build for app (它编译“my”):
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.app.id"
minSdkVersion 18
targetSdkVersion 25
versionCode 5
versionName "1.4"
}
sourceSets {
main {
assets.srcDirs = [project.ext.ASSET_DIR]
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':my-library')
}我的图书馆的gradle.build:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 18
targetSdkVersion 25
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}发布于 2017-05-25 19:49:01
事实证明,Android足够聪明地处理带有res文件夹的库模块。我的错误来自于“宣言”文件中的冲突。
https://stackoverflow.com/questions/44171732
复制相似问题