# android-key

> वह command जिससे एजेंट टीम की Android signing keys मैनेज करते हैं: उनकी सूची देखना, जाँचना, बनाना, import करना, वापस लाना और export करना।

Source: https://air.build/hi/docs/cli/android-key/

`android-key` टीम की Android app keys मैनेज करता है। AirBuild हर Android ऐप के लिए एक active key रखता है, और उस ऐप का हर build उसी से sign होता है: emulator `.apk`, लोगों के डाउनलोड करने वाला APK, और `runbuild --sign` से बने releases। बदली गई key archive होती है, कभी डिलीट नहीं होती, और उसे फिर से active किया जा सकता है।

## यह कहाँ चलता है

यही command cloud टीम और Mac टीम, दोनों के एजेंट्स के लिए उपलब्ध है। Sign-in एजेंट के environment से आता है, इसलिए कुछ सेट नहीं करना पड़ता। Command को `curl` और `jq` चाहिए, जो environment देता है। देखें [चुनें कि आपके एजेंट कहाँ चलें](https://air.build/hi/docs/get-started/where-agents-run/)।

## ऐप को उसकी key कैसे मिलती है

- **अपने आप।** ऐप का पहला build, जब उसकी कोई active key नहीं होती, एक key बना देता है। इसका origin `auto` होता है।
- **Chat card से।** एजेंट एक `android_upload_key` card भेज सकता है; व्यक्ति उस पर कोई मौजूदा keystore अपलोड करता है या नई key बनाता है।
- **इस command से।** जब व्यक्ति chat में keystore attach करे तो `import`, और जब वह शब्दों में नई key माँगे तो `create`।

`create` सिर्फ़ तब करें जब व्यक्ति ने नई key माँगी हो, या ऐप Google Play पर नया हो। जो ऐप पहले से Google Play पर है, उसे अपनी upload key बनाए रखनी होगी।

## Synopsis

```text
android-key list [--json]
android-key status PACKAGE [--json]
android-key create --package PACKAGE [--json]
android-key import FILE --package PACKAGE [--password-entry NAME [--password-field LABEL]] [--json]
android-key activate PACKAGE KEY_ID [--json]
android-key certificate PACKAGE [--key KEY_ID] [--output FILE] [--json]
android-key export PACKAGE [--key KEY_ID] [--output FILE] [--json]
android-key --help
```

`PACKAGE` ऐप का `applicationId` है, जैसे `com.example.app`: dot से अलग कम से कम दो हिस्से, हर एक letter से शुरू होता हुआ, 150 characters तक। `status`, `create`, `certificate` और `export` इसे या तो पहले argument के रूप में लेती हैं या `--package PACKAGE` के रूप में।

## Commands

| Command | यह क्या करती है |
| --- | --- |
| `list` | टीम के पास हर ऐप की सभी keys, active और archived। |
| `status PACKAGE` | ऐप की active key, फिर उसकी archived keys। |
| `create` | ऐप के लिए नई key बनाकर उसे active करती है। ऐप की पहले वाली key archive हो जाती है। |
| `import FILE` | Keystore AirBuild को भेजती है, जो उसे जाँचकर उसकी key को ऐप की active key के रूप में रखता है। ऐप की पहले वाली key archive हो जाती है। |
| `activate PACKAGE KEY_ID` | किसी archived key को फिर active करती है; active key archive हो जाती है। `status` ids दिखाती है। |
| `certificate PACKAGE` | Key का certificate PEM के रूप में दिखाती है। सिर्फ़ certificate, कोई private key नहीं। |
| `export PACKAGE` | Key को एक keystore file और उसके बगल में एक `.properties` file के रूप में लिखती है। सिर्फ़ तब जब व्यक्ति अपनी key माँगे। |

Active key ऐप के हर आगे के build को sign करती है, emulator `.apk` समेत।

## Options

| Option | Commands | Value | Default | मतलब |
| --- | --- | --- | --- | --- |
| `--package` | `status`, `create`, `import`, `certificate`, `export` | एक `applicationId` | — | ऐप। `create` और `import` के लिए ज़रूरी। |
| `--key` | `certificate`, `export` | Key id (UUID) | Active key | कौन-सी key। |
| `--output` | `certificate` | एक file | stdout पर दिखाना | PEM को इस file में लिखता है। |
| `--output` | `export` | एक file | `./PACKAGE.keystore` | Keystore कहाँ लिखना है। न यह और न `FILE.properties` पहले से मौजूद होनी चाहिए। |
| `--password-entry` | `import` | Passwords entry का नाम | stdin से पढ़ा जाता है | Keystore password टीम के Passwords से पढ़ता है। |
| `--password-field` | `import` | Field label | `Password` | `--password-entry` का वह field जिसमें password है। |
| `--json` | सभी | — | Off | Text की जगह JSON जवाब दिखाता है। Error पर stderr पर JSON error भी दिखाता है। |

## Keystore import करना

- `FILE` व्यक्ति का keystore है, अधिकतम 64 KiB।

- यह **PKCS#12** होना चाहिए: वही जो आज Android Studio और `keytool` बनाते हैं, अक्सर अब भी `.jks` नाम के साथ। पुराना JKS format supported नहीं है। व्यक्ति से इसे convert करने, या Android Studio से फिर से export करने को कहें:

  ```bash
  keytool -importkeystore -srckeystore FILE -destkeystore upload.p12 -deststoretype pkcs12
  ```

- PKCS#12 keystore का एक ही password होता है। यह stdin की पहली line से, या `--password-entry` के साथ टीम Passwords की किसी entry से पढ़ा जाता है। Passwords कभी command line पर नहीं जाते: `--password` या `--store-password` जैसे options ठुकरा दिए जाते हैं। व्यक्ति से password `request_password` card से माँगें, chat में कभी नहीं (देखें [password-book](https://air.build/hi/docs/cli/password-book/))।

- AirBuild password जाँचता है, और यह भी कि key अपने certificate से मेल खाती है।

- सफल import के बाद command आपको keystore file और आपकी बनाई कोई भी दूसरी कॉपी डिलीट करने की याद दिलाती है।

## Key export करना

`export` दो files लिखती है, दोनों सिर्फ़ उनके owner के पढ़ने लायक (mode 600):

```text
PACKAGE.keystore             a PKCS#12 keystore, key alias "upload"
PACKAGE.keystore.properties  storeFile, storePassword, keyAlias, keyPassword
```

Properties file ऐसी दिखती है, असली password के साथ:

```text
storeFile=com.example.app.keystore
storePassword=...
keyAlias=upload
keyPassword=...
```

हर export का password नया होता है। कुछ भी गुप्त नहीं दिखाया जाता, और properties file भी नहीं दिखानी चाहिए। दोनों files सिर्फ़ उसी व्यक्ति को भेजें जिसने माँगी हैं, फिर अपनी कॉपियाँ डिलीट करें।

## Output

`list`:

```text
PACKAGE          STATUS    ORIGIN    SHA-256                 ID
com.example.app  active    imported  3FA1…                   <key-id>
```

कोई key न हो तो यह `The Team holds no Android upload keys yet.` दिखाती है।

`status`, और `create`, `import` व `activate` के output में हर key:

```text
Active key for com.example.app:
  id           <key-id>
  status       active
  origin       created
  sha256       <certificate fingerprint>
  valid until  2051-11-19
  created      2026-11-19 by <id>
```

`status` हर archived key को इसी तरह `Archived:` के नीचे दिखाती है। बिना active key वाले ऐप के लिए यह दिखता है: `com.example.app has no active upload key. The first signed build creates one; if the app is already on Google Play, import its keystore first.`

`sha256` certificate का SHA-256 fingerprint है, वही जो Google Play Console दिखाता है। `origin` `auto`, `created` या `imported` होता है; `status` `active` या `archived` होता है।

`create`, `import` और `activate` `This key now signs com.example.app:` और key दिखाती हैं, फिर, अगर कोई दूसरी key बदली गई, तो `Archived (restore with android-key activate com.example.app <key-id>):` और वह key। कुछ न बदला हो तो वे `Nothing changed: this key already signs com.example.app.` दिखाती हैं।

`export` paths, key id और fingerprint दिखाती है:

```text
Wrote the active key for com.example.app (PKCS#12, alias upload, mode 600):
  keystore    ./com.example.app.keystore
  properties  ./com.example.app.keystore.properties  (storePassword, keyPassword, keyAlias; not shown here)
  id          <key-id>
  sha256      <certificate fingerprint>
Send both files only to the person who asked for them, then delete your copies.
```

## Exit codes

| Code | मतलब |
| --- | --- |
| `0` | सफल। |
| `1` | AirBuild ने request ठुकरा दी, या कोई file पढ़ी या लिखी नहीं जा सकी। |
| `2` | Usage error: अनजान command या option, कोई argument छूटा, या गलत रूप में value। इसके बाद `Run 'android-key --help' for usage.` आता है। |

जब AirBuild कोई request ठुकराता है, तो command `Error: <reason>` और अगली line पर `Code: <code>` दिखाती है। Reason बताता है कि क्या करना है।

## Errors

Command के अपने messages `Error:` से शुरू होते हैं; AirBuild के ठुकराने पर एक `Code:` line भी जुड़ती है।

| Message या code | क्या करें |
| --- | --- |
| `'…' is not an Android applicationId (such as com.example.app).` | ऐप का `applicationId` दें। |
| `'…' is not a key id (android-key status shows them).` | Id `android-key status` से कॉपी करें। |
| `passwords never go on the command line. Pipe it on stdin or use --password-entry NAME.` | Password pipe करें, या उसे टीम के Passwords में सेव करके `--password-entry` इस्तेमाल करें। |
| `pipe the keystore password on stdin, or pass --password-entry NAME.` | वही। |
| `a PKCS#12 keystore has one password; name its field with --password-field.` | अलग key-password option की जगह `--password-field` इस्तेमाल करें। |
| `could not read "Password" from the Passwords entry "…".` | `password-book get NAME` से entry और field के नाम जाँचें। |
| `cannot read the keystore '…'.` / `the keystore '…' is empty.` | File path जाँचें। |
| `the keystore is larger than 64 KiB; it is not an upload keystore.` | व्यक्ति से सही file माँगें। |
| `android_keystore_jks_unsupported` | File पुराने JKS format में है। इसे ऊपर दी गई `keytool` command से convert करवाएँ, या Android Studio से फिर export करवाएँ। |
| `android_keystore_password_wrong` | Password से keystore नहीं खुलता। व्यक्ति से सही password माँगें। |
| `android_keystore_multiple_keys` | Keystore में एक से ज़्यादा private keys हैं। सिर्फ़ upload key वाला keystore माँगें। |
| `android_keystore_key_mismatch` | Keystore का कोई certificate उसकी key से मेल नहीं खाता। |
| `android_keystore_invalid` | File को keystore के रूप में पढ़ा नहीं जा सका। |
| `'…' already exists; move it away or pass another --output.` | `export` कभी overwrite नहीं करती; कोई और path चुनें। |
| `--output '…' is a directory; name the keystore file.` | एक file name दें। |

## उदाहरण

ऐप की active key और उसका fingerprint देखें:

```bash
android-key status com.example.app
```

व्यक्ति का attach किया keystore import करें, जिसका password टीम के Passwords में सेव है:

```bash
android-key import upload.jks --package com.example.app \
  --password-entry "Android keystore com.example.app"
```

Upload certificate को एक file में सेव करें:

```bash
android-key certificate com.example.app --output upload_certificate.pem
```

बदली गई key वापस लाएँ:

```bash
android-key activate com.example.app 0b7c2d3e-0000-4000-8000-000000000000
```
