[俺メモ]新しいTitanium SDK がでたらやること

More than 1 year has passed since last update.

当然ダウンロードは済んでいる前提。

Android アプリ作成時の署名方法変更

なんでそんなことが必要なの?は、こちらのページを参照のこと。

android/builder.py
def get_sigalg(self):
    output = run.run([self.keytool,
        '-v',
        '-list',
        '-keystore', self.keystore,
        '-storepass', self.keystore_pass,
        '-alias', self.keystore_alias
    ], protect_arg_positions=(6,))

    # If the keytool encounters an error, that means some of the provided
    # keychain info is invalid and we should bail anyway
    run.check_output_for_error(output, r'RuntimeException: (.*)', True)
    run.check_output_for_error(output, r'^keytool: (.*)', True)

    #
    # ここを変更
    # Edited by sngmr for Error installing apk
    #
    match = re.search(r'Signature algorithm name: (.*)', output)
    if match is not None:
        if match.group(1) == "SHA256withRSA":
            return "SHA1withRSA"
        else:
            return match.group(1)

    # Return the default:
    return "MD5withRSA"
android/cli/commands/_build.js
// 320行目付近
    validate: function (value, callback) {
        // if there's a value, then they entered something, otherwise let the cli prompt
        if (value) {
            var selectedAlias = value.toLowerCase(),
                alias = _t.keystoreAlias = _t.keystoreAliases.filter(function (a) { return a.name && a.name.toLowerCase() == selectedAlias; }).shift();
            if (!alias) {
                return callback(new Error(__('Invalid "--alias" value "%s"', value)));
            }
            if (alias.sigalg && alias.sigalg.toLowerCase() == 'sha256withrsa') {
                logger.warn(__('The selected alias %s uses the %s signature algorithm which will likely have issues with Android 4.3 and older.', ('"' + value + '"').cyan, ('"' + alias.sigalg + '"').cyan));
                logger.warn(__('Certificates that use the %s or %s signature algorithm will provide better compatibility.', '"SHA1withRSA"'.cyan, '"MD5withRSA"'.cyan));

                // ここを追加 for Java 7 で Keystore を作ってしまってるのの対応
                logger.warn(__('Force change %s to %s', ('"' + alias.sigalg + '"').cyan, '"SHA1withRSA"'.cyan));
                alias.sigalg = 'SHA1withRSA';
            }
        }
        callback(null, value);
    }

以下はもう不要だと思う。Titaniumが公式にGenymotion対応したから。

Genymotion対応

対応の詳細はこちら

android/androidsdk.py
def list_devices(self):
    adb = self.get_adb()
    (out, err) = subprocess.Popen([adb, 'devices'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    if type(err) != types.NoneType and len(err) > 0:
        raise Exception(err)
    devices = []
    for line in out.splitlines():
        line = line.strip()
        if line.startswith("List of devices"): continue
        elif line.startswith("emulator-"):
            (name, status) = line.split()
            port = int(name[name.index("-")+1:])
            offline = False
            if status == "offline":
                offline = True
            devices.append(Device(name, port, True, offline))
        # Added by sngmr
        elif line.startswith("192.168.56."):
            (name, status) = line.split()
            port = int(name[name.index(":")+1:])
            offline = False
            if status == "offline":
                offline = True
            devices.append(Device(name, port, True, offline))
        elif "device" in line:
            name = line.split()[0]
            devices.append(Device(name))
    return devices
android/cli/commands/_build.js
// 448行目付近
// Changed by sngmr
emulatorProcess = spawn('python', ['--version'], { detached: true, stdio: 'ignore' });
// emulatorProcess = spawn('python', emulatorCmd, { detached: true, stdio: 'ignore' });

///
/// 中略
///

// 465行目付近
devicesProcess.on('exit', function (code, status) {
    if (results.indexOf('emulator') != -1) {
        logger.info(__('Emulator is running') + '\n');
    // Addedn by sngmr
    } else if (results.indexOf('192.168.56.') != -1) {
        logger.info(__('AndroVM Emulator is running') + '\n');
    } else {
        emulatorRunning = false;
        logger.info(__('Emulator process exited successfully') + '\n');
        logcatProcess && logcatProcess.kill('SIGKILL');
        adbProcess && adbProcess.kill('SIGKILL');
        buildProcess && buildProcess.kill('SIGKILL');
        emulatorProcess = buildProcess = logcatProcess = adbProcess = null;
    }
});