如何从Android Studio构建所有产品风格?

如何从Android Studio构建所有产品风格?,android,android-studio,gradle,build,android-gradle-plugin,Android,Android Studio,Gradle,Build,Android Gradle Plugin,我在gradle文件中有很多口味: def _versionName = "1.19" def _applicationId = "com.site.app" productFlavors { CafebazarPro { applicationId "${_applicationId}" versionName "${_versionName}" +"-Cafebazar-Pro"

我在gradle文件中有很多口味:

      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"
        }
     }

如何自动构建所有口味?不要逐个选择和构建。

打开Cmd并运行以下命令:

gradlew任务

gradlew Assembly-组装所有应用程序和应用程序的所有变体 二级包


问题是,是否有可能使用android studio构建所有口味。所以这可能对将来的人有所帮助

从右侧工具栏或从中使用“渐变”选项 查看->工具窗口->渐变(如果渐变在工具栏上不可见)

然后导航到您的项目->任务->构建单击下面提到的所需选项以启动相应的构建

  • 组装:组装所有版本的调试版本和发布版本(需要很多时间)
  • 组装AndroidTest:组装所有android单元测试
  • assembleChocolate:组装调试版和发布版的巧克力口味
  • assembleDebug:只汇编所有风格的调试版本(我在进行影响所有风格的更改时使用此选项,以确保所有风格都已生成)
  • 组装轻松:只组装所有口味的发行版
  • 组装草莓口味:组装草莓口味的调试版和发行版
  • 组装Evanila:组装香草香精的调试版和发布版

  • 荣誉:)

    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