How to set name of AAR output from Gradle

后端 未结 7 440
一整个雨季
一整个雨季 2021-01-30 10:18

I have a project with several modules in it one of which is a Android Library named (poorly) as sdk. When I build the project it outputs an AAR named sdk.aar<

相关标签:
7条回答
  • 2021-01-30 11:07

    Using Gradle 6+ and AGP 4+, an alternative answer that allows full control of the name is:

    afterEvaluate {
        android.libraryVariants.all { variant ->
            variant.variantData.outputFactory.apkDataList.each { apkData ->
                if (apkData.outputFileName.endsWith('.aar')) {
                    apkData.outputFileName = "${project.name}-${buildType.name}-anything-you-want.aar"
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题