Example #1
0
def Main():
    (options, args) = parse_options()
    apks = []
    is_split = options.split
    run_aapt_pack(options.aapt, options.api, options.app)
    if is_split:
        run_aapt_split_pack(options.aapt, options.api, options.app)
    compile_with_javac(options.api, options.app)
    dex(options.app, options.api)
    dex_files = {options.app: get_dex_path(options.app)}
    dex_path = get_dex_path(options.app)
    if is_split:
        split(options.app)
        dex_path = get_split_path(options.app, 'base')

    temp_apk_path = create_temp_apk(options.app, '')
    aapt_add_dex(options.aapt, dex_path, temp_apk_path)
    apk_path = os.path.join(get_bin_path(options.app), '%s.apk' % options.app)
    apk_utils.sign(temp_apk_path, apk_path, options.keystore)
    apks.append(apk_path)

    if is_split:
        split_temp_apk_path = create_temp_apk(options.app, 'split_')
        aapt_add_dex(options.aapt, get_split_path(options.app, 'split'),
                     temp_apk_path)
        split_apk_path = os.path.join(get_bin_path(options.app),
                                      'featuresplit.apk')
        apk_utils.sign(temp_apk_path, split_apk_path, options.keystore)
        apks.append(split_apk_path)

    print('Generated apks available at: %s' % ' '.join(apks))
    if options.install or options.benchmark:
        adb_install(apks)
    grand_total = 0
    if options.benchmark:
        ensure_no_logcat()
        for _ in range(BENCHMARK_ITERATIONS):
            grand_total += benchmark(options.app, options.benchmark_output_dir)
    print 'Combined average: %s' % (grand_total / BENCHMARK_ITERATIONS)
Example #2
0
def sign(unsigned_apk, keystore, temp, quiet):
    signed_apk = os.path.join(temp, 'unaligned.apk')
    apk_utils.sign(unsigned_apk, signed_apk, keystore, quiet=quiet)
    return signed_apk