Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kirin233x opened this issue Oct 20, 2022 · 11 comments

Comments

@kirin233x
Copy link

kirin233x commented Oct 20, 2022

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
Copy link
Author

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
Copy link
Author

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

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

@kirin233x
Copy link
Author

kirin233x commented Oct 21, 2022

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

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

@genamendola17
Copy link

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

@kirin233x
Copy link
Author

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.

@genamendola17
Copy link

@kirin521 I resolved with AGP 7.2.2

@kirin233x
Copy link
Author

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

@meavydev
Copy link

meavydev commented Oct 31, 2022

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

@lhjandroid
Copy link

lhjandroid commented Nov 1, 2022

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

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

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

@meavydev
Copy link

meavydev commented Nov 1, 2022

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.

@kirin233x kirin233x changed the title 1.3.8的fat-aar版本,配合7.4的gradle,资源文件没merge到一起,class什么的都merge到一起了。 1.3.8的fat-aar版本,AGP 7.3 Gradle7.4,资源文件没merge到一起,class什么的都merge到一起了。 Nov 1, 2022
@kirin233x
Copy link
Author

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

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants