我想创建第二个构建类型,它应该与现有的调试类型完全一样。目前我有两种构建类型:调试和发布。只需单击即可运行调试,并使用调试 keystore 自动签名。
我通过 Build -> Generate signed APK
向导手动编译发布版本。
所以为了克隆调试构建类型,我首先在 app build.graddle 文件中添加了第二个名为“local”的构建类型:
buildTypes {
...
debug {
debuggable true
minifyEnabled false
}
local {
debuggable true
minifyEnabled false
}
}
然后我创建了 app/src/local/res
并添加了一些文件。
然后我执行 gradle resync 并在左侧选项卡中选择新的构建类型:
最后我点击了运行按钮,我希望它能够正常工作。这个IntelliJ help article说调试签名配置是默认的:
This means that if you do not configure an artifact manually and select the Deploy default APK option in the Run/Debug Configuration: Android Application dialog box, IntelliJ IDEA will use the predefined values in the certificate for the generated
而是显示此对话框:
当我单击修复按钮时,它会打开整个应用模块的签名配置对话框。但是,我不想签署此 apk 以进行发布,我需要使用调试证书对其进行签名。我还注意到已经创建了一个新的 assembleLocal
gradle 任务,但它会生成一个未对齐的 apk。在此文件夹中,我可以看到常规调试 apk 在其未对齐版本和最终版本中正确生成。
到底如何才能克隆调试构建类型?
最佳答案
此外,您可以使用以下命令使您的构建类型类似于调试:
initWith(buildTypes.debug)
这是一个例子:
...
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField 'String', 'URL_API_BASE_SERVICE', '"http://theidasworld.com"'
}
debug {
versionName 'APP BETA'
buildConfigField "Integer", "PIN", "0000"
buildConfigField 'String', 'URL_API_BASE_SERVICE', '"http://debug.theidasworld.com"'
}
inspection {
initWith(buildTypes.debug) // keep versionName and PIN from 'debug'
buildConfigField 'String', 'URL_API_BASE_SERVICE', '"http://inspection.theidasworld.com"'
}
}
...
关于安卓工作室 : how to create a second debug build type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35033748/