在我的项目中,我添加了一个像
这样的依赖compile'cn.coderyu:library:1.4.0-SNAPSHOT
并且在库的build.gradle文件中,我有配置
manifestPlaceholders.put("SECURITY_FILE",getSecurityFile())
String getSecurityFile() {
if (project.hasProperty('HTTPS_CATCHABLE') && project.HTTPS_CATCHABLE.toLowerCase() == 'true' ) {
return "@xml/network_security_config"
}
return "@null"
}
并在库的清单文件中添加
<application
android:networkSecurityConfig="${SECURITY_FILE}"
android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">
当我运行构建命令
时gradle assembleRelease -PHTTPS_CATCHABLE=true
发布的apk中的清单文件是
<application
android:networkSecurityConfig="@null"
android:allowBackup="true" android:label="mytest"
android:supportsRtl="true">
如果我将库作为子模块导入,则命令有效