Open kirin233x opened 1 year ago
Firstlibaray:
second:
plugins {
id 'com.android.library'
id 'com.kezong.fat-aar'
}
android {
namespace 'com.huawei.mylibrarysecond'
compileSdk 32
defaultConfig {
minSdk 21
targetSdk 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compileOnly project(':mylibraryfirst')
embed project(':mylibraryfirst')
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
结果:
我又试了一下,通过在second的gradle里面,添加sourceset sourceSets{ debug.res.srcDirs = ['src/main/res', 'build/intermediates/exploded-aar/fataarissue399/mylibraryfirst/unspecified/debug/res'] }
是可以生效的。怀疑是不是processResources的时序有问题。不是很懂。=-=
又研究了一下,看起来是因为这笔提交导致的。AGP 7.3.0以上就有问题了。 https://cs.android.com/android-studio/platform/tools/base/+/21679fcbbafd4af740fdc9427fe548cff0f15918
可能要更改一下设置sourcesets的时机,大佬有空帮忙瞅瞅~,感谢。
Hi, i have the same problema but i have more embed project. how can I solve this problem? Ty
Hi, i have the same problema but i have more embed project. how can I solve this problem? Ty sorry, I haven't found a solution yet.
@kirin521 I resolved with AGP 7.2.2
Yes, I downgrade the gradle version to 7.2.2 to circumvent this problem.
I haven't really built Gradle plug-ins before, so I am definitely not an expert, but it appears that the resources are merged correctly into the R.txt, but the aar_rebundle directory needs to have the res contents from all the bundled AARs (and possibly a merged values.xml). I got it working locally by updating the configureReBundleAarTask like this (not doing a PR, as it could be the wrong way of solving this...) fat_aar_res.txt
如果是assets没合并进去可以这样做
sourceSets {
main {
assets.srcDirs = ['src/main/assets']
}
}
同时加在你有资源的module和主包下
If the comment about assets was to me, then the issue is not assets. None of the res folder is getting into the re-bundled AAR, so no fonts / layouts / values etc.
如果是assets没合并进去可以这样做
sourceSets { main { assets.srcDirs = ['src/main/assets'] } }
同时加在你有资源的module和主包下
AGP7.3.0下生效吗?我试了一下好像不行哎
1.3.8的fat-aar版本,配合7.4的gradle,AGP是7.3.0. 资源文件没merge到一起,class什么的都merge到一起了。 res下的只生成了一个values目录,其他的多语言都丢失了。fat-aar没有什么异常日志。
Build Environment