Gradle How to exclude files from apk

前端 未结 1 841
执念已碎
执念已碎 2021-01-14 11:48

I store my keystore at my assets directory. How can exclude it in the build to create the .apk?

I tried in that way but still there:

android {
    ..         


        
相关标签:
1条回答
  • 2021-01-14 12:05

    Try with next:

        ...
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
        }
    }
    
    android.applicationVariants.all { variant ->
        //if (variant.name.contains('Release')) { // exclude source and sourcemap from release builds
        def rmkeystore = task("delete${variant.name}.rmkeystore", type: Delete) {
            delete "${buildDir}/intermediates/assets/${variant.dirName}/keystore"
        }
        variant.mergeAssets.finalizedBy rmkeystore
        //}
    }
    

    Ref: https://stackoverflow.com/a/29168827/717267

    0 讨论(0)
提交回复
热议问题