fat-aar-android icon indicating copy to clipboard operation
fat-aar-android copied to clipboard

1.3.8的fat-aar版本,AGP 7.3 Gradle7.4,资源文件没merge到一起,class什么的都merge到一起了。

Open kirin233x opened this issue 3 years ago • 11 comments

1.3.8的fat-aar版本,配合7.4的gradle,AGP是7.3.0. 资源文件没merge到一起,class什么的都merge到一起了。 res下的只生成了一个values目录,其他的多语言都丢失了。fat-aar没有什么异常日志。

Build Environment

  • Operating System: Windows
  • Gradle Plugin Version: 7.3.1
  • Gradle Version: 7.4
  • Fat-aar Version: 1.3.8

kirin233x avatar Oct 20 '22 11:10 kirin233x

Firstlibaray: image

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'
}

结果: image

kirin233x avatar Oct 20 '22 13:10 kirin233x

我又试了一下,通过在second的gradle里面,添加sourceset sourceSets{ debug.res.srcDirs = ['src/main/res', 'build/intermediates/exploded-aar/fataarissue399/mylibraryfirst/unspecified/debug/res'] }

是可以生效的。怀疑是不是processResources的时序有问题。不是很懂。=-=

kirin233x avatar Oct 21 '22 06:10 kirin233x

又研究了一下,看起来是因为这笔提交导致的。AGP 7.3.0以上就有问题了。 https://cs.android.com/android-studio/platform/tools/base/+/21679fcbbafd4af740fdc9427fe548cff0f15918

可能要更改一下设置sourcesets的时机,大佬有空帮忙瞅瞅~,感谢。

kirin233x avatar Oct 21 '22 08:10 kirin233x

Hi, i have the same problema but i have more embed project. how can I solve this problem? Ty

genamendola17 avatar Oct 21 '22 11:10 genamendola17

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.

kirin233x avatar Oct 24 '22 01:10 kirin233x

@kirin521 I resolved with AGP 7.2.2

genamendola17 avatar Oct 26 '22 10:10 genamendola17

Yes, I downgrade the gradle version to 7.2.2 to circumvent this problem.

kirin233x avatar Oct 27 '22 01:10 kirin233x

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

meavydev avatar Oct 31 '22 10:10 meavydev

如果是assets没合并进去可以这样做

sourceSets {
        main {
            assets.srcDirs = ['src/main/assets']
        }
    }

同时加在你有资源的module和主包下

lhjandroid avatar Nov 01 '22 09:11 lhjandroid

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.

meavydev avatar Nov 01 '22 10:11 meavydev

如果是assets没合并进去可以这样做

sourceSets {
        main {
            assets.srcDirs = ['src/main/assets']
        }
    }

同时加在你有资源的module和主包下

AGP7.3.0下生效吗?我试了一下好像不行哎

kirin233x avatar Nov 01 '22 11:11 kirin233x