Fastfile lane 用于构建和安装给定构建类型的所有 flavor 到设备

将此通道添加到 Fastfile 并在命令行中运行 fastlane installAll type:{BUILD_TYPE}。将 BUILD_TYPE 替换为你要构建的构建类型。

例如:fastlane installAll type:Debug

此命令将构建给定类型的所有类型并将其安装到你的设备。目前,如果你连接了多个设备,它将不起作用。确保你只有一个。将来我计划添加选择目标设备的选项。

lane :installAll do |options|

    gradle(task: "clean")

    gradle(task: "assemble",
       build_type: options[:type])

    lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].each do | apk |

        puts "Uploading APK to Device: " + apk

        begin
            adb(
                command: "install -r #{apk}"
            )
        rescue => ex
            puts ex
        end
    end
end