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