在Android项目的主module下面的build.gradle文件中的android标签里面加入一下代码:
//解决真机 INSTALL_FAILED_TEST_ONLY安装失败的问题
applicationVariants.all { variant ->
if (variant.name.contains("debug")) {
println("variant.name: " + variant.name);
variant.outputs.each { output ->
output.processManifest.doLast {
String manifestPath = "${buildDir}/intermediates/merged_manifests/${variant.name}/AndroidManifest.xml"
def manifestContent = file(manifestPath).getText('UTF-8')
manifestContent = manifestContent.replaceAll("android:testOnly=\"true\"", "android:testOnly=\"false\"")
file(manifestPath).write(manifestContent, 'UTF-8')
}
}
}
}
网友评论