网上找了一个开源项目,在打release包时报了一下异常:
Error:A problem was found with the configuration of task ':app:packageQqRelease'.
> File 'F:\android\code\open_source_projects\MultiChannel-master-master\app\build\intermediates\res\resources-qq-release-stripped.ap_' specified for property 'resourceFile' does not exist.
搜资料后,发现是 shrinkResourcestrue引起的问题:如下
release { // release模式下,不显示log buildConfigField("boolean", "LOG_DEBUG", "false") // 为版本名添加后缀 versionNameSuffix "-relase" // 不开启混淆 minifyEnabled false // 开启ZipAlign优化 zipAlignEnabled true // 移除无用的resource文件 shrinkResources true // 使用config签名 // signingConfig signingConfigs.config // 混淆文件位置 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' }
shrinkResources改为false后就OK了,可以正常打包并安装。又在另外一篇文章里看到,shrinkResources
和minifyEnabled必须要一起用,即shrinkResources和minifyEnabled要么同为false,要么同为true。
我试着改了看,结果的确可以正常打包安装。