本文介绍了如何从 Android Studio 构建所有产品风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 gradle 文件中有很多风格:
def _versionName = "1.19"def _applicationId = "com.site.app"产品风味{CafebazarPro {applicationId "${_applicationId}"versionName "${_versionName}" +"-Cafebazar-Pro"}CafebazarInPurchase {applicationId "${_applicationId}.inpurchase"versionName "${_versionName}" +"-Cafebazar-InPurchase"}//--------------------------------------------可以做 {applicationId ${_applicationId}"versionName "${_versionName}" +"-Cando-Pro"}//--------------------------------------------我的{applicationId "${_applicationId}"versionName "${_versionName}" +"-Myket-Pro"}//--------------------------伊朗应用{applicationId "${_applicationId}"versionName "${_versionName}" +"-IranApps-Pro"}}
如何自动构建所有口味?不一一选择构建.
解决方案
打开 Cmd 并运行此命令:
gradlew 任务
构建任务-----------assemble - 组装所有应用程序和辅助包的所有变体.assembleAndroidTest - 组装所有测试应用程序.assembleDebug - 组装所有调试版本.assembleRelease - 组装所有发布版本.build - 组装和测试这个项目.buildDependents - 组装和测试这个项目和所有依赖它的项目.buildNeeded - 组装和测试此项目及其依赖的所有项目.classes - 组装主要类.clean - 删除构建目录.compileDebugAndroidTestSources编译调试源compileDebugUnitTestSources编译发布源compileReleaseUnitTestSourcesjar - 组装包含主要类的 jar 档案.mockableAndroidJar - 创建一个适合单元测试的 android.jar 版本.testClasses - 组装测试类.构建设置任务-----------------init - 初始化一个新的 Gradle 构建.[孵化]包装器 - 生成 Gradle 包装器文件.[孵化]文档任务-------------------javadoc - 为主源代码生成 Javadoc API 文档.帮助任务----------buildEnvironment - 显示在根项目src"中声明的所有构建脚本依赖项.组件 - 显示由根项目 'src' 生成的组件.[孵化]依赖项 - 显示在根项目src"中声明的所有依赖项.dependencyInsight - 显示对根项目src"中特定依赖项的洞察.help - 显示帮助消息.模型 - 显示根项目 'src' 的配置模型.[孵化]项目 - 显示根项目src"的子项目.属性 - 显示根项目src"的属性.任务 - 显示可从根项目 'src' 运行的任务(某些显示的任务可能属于子项目).安装任务-------------installDebug - 安装调试版本.installDebugAndroidTest - 为 Debug 版本安装 android(在设备上)测试.uninstallAll - 卸载所有应用程序.uninstallDebug - 卸载调试版本.uninstallDebugAndroidTest - 卸载 Debug 版本的 android(在设备上)测试.uninstallRelease - 卸载发布版本.验证任务------------------check - 运行所有检查.connectedAndroidTest - 在连接的设备上安装和运行所有风格的仪器测试.connectedCheck - 在当前连接的设备上运行所有设备检查.connectedDebugAndroidTest - 在连接的设备上安装并运行调试测试.deviceAndroidTest - 使用所有设备提供程序安装和运行仪器测试.deviceCheck - 使用设备提供程序和测试服务器运行所有设备检查.lint - 在所有变体上运行 lint.lintDebug - 在调试版本上运行 lint.lintRelease - 在发布版本上运行 lint.test - 为所有变体运行单元测试.testDebugUnitTest - 为调试版本运行单元测试.testReleaseUnitTest - 为发布版本运行单元测试.其他任务-----------干净的jar调试类jarRelease 类transformResourcesWithMergeJavaResForDebugUnitTesttransformResourcesWithMergeJavaResForReleaseUnitTest
gradlew assemble - 组装所有应用程序的所有变体和二次包.
I have many flavors in gradle file :
def _versionName = "1.19"
def _applicationId = "com.site.app"
productFlavors {
CafebazarPro {
applicationId "${_applicationId}"
versionName "${_versionName}" +"-Cafebazar-Pro"
}
CafebazarInPurchase {
applicationId "${_applicationId}.inpurchase"
versionName "${_versionName}" +"-Cafebazar-InPurchase"
}
//-------------------------------------------
Cando {
applicationId ${_applicationId}"
versionName "${_versionName}" +"-Cando-Pro"
}
//-------------------------------------------
Myket {
applicationId "${_applicationId}"
versionName "${_versionName}" +"-Myket-Pro"
}
//-----------------------------------------
IranApps {
applicationId "${_applicationId}"
versionName "${_versionName}" +"-IranApps-Pro"
}
}
How to build automatically all flavors ? not select and build one by one .
解决方案
Open Cmd and run this command :
Build tasks
-----------
assemble - Assembles all variants of all applications and secondary packages.
assembleAndroidTest - Assembles all the Test applications.
assembleDebug - Assembles all Debug builds.
assembleRelease - Assembles all Release builds.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles main classes.
clean - Deletes the build directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
jar - Assembles a jar archive containing the main classes.
mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests.
testClasses - Assembles test classes.
Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]
Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.
Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'src'.
components - Displays the components produced by root project 'src'. [incubating]
dependencies - Displays all dependencies declared in root project 'src'.
dependencyInsight - Displays the insight into a specific dependency in root project 'src'.
help - Displays a help message.
model - Displays the configuration model of root project 'src'. [incubating]
projects - Displays the sub-projects of root project 'src'.
properties - Displays the properties of root project 'src'.
tasks - Displays the tasks runnable from root project 'src' (some of the displayed tasks may belong to subprojects).
Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.
Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testReleaseUnitTest - Run unit tests for the release build.
Other tasks
-----------
clean
jarDebugClasses
jarReleaseClasses
transformResourcesWithMergeJavaResForDebugUnitTest
transformResourcesWithMergeJavaResForReleaseUnitTest
这篇关于如何从 Android Studio 构建所有产品风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!