{"id":20675830,"url":"https://github.com/leoliu0605/github-actions-kotlin","last_synced_at":"2025-05-10T15:30:29.177Z","repository":{"id":220601448,"uuid":"752071779","full_name":"leoli0605/github-actions-kotlin","owner":"leoli0605","description":"A very SIMPLE example to show how to build an Android Kotlin app with GitHub Actions.","archived":false,"fork":false,"pushed_at":"2024-03-16T12:57:59.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-28T03:34:12.371Z","etag":null,"topics":["android","android-app","android-kotlin","android-kotlin-example","dockerfile","github-actions","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leoli0605.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-03T00:21:51.000Z","updated_at":"2024-03-27T17:16:08.000Z","dependencies_parsed_at":"2024-03-10T06:35:24.008Z","dependency_job_id":null,"html_url":"https://github.com/leoli0605/github-actions-kotlin","commit_stats":null,"previous_names":["leoli0605/github-actions-kotlin"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoli0605%2Fgithub-actions-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoli0605%2Fgithub-actions-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoli0605%2Fgithub-actions-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoli0605%2Fgithub-actions-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoli0605","download_url":"https://codeload.github.com/leoli0605/github-actions-kotlin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224970060,"owners_count":17400294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-app","android-kotlin","android-kotlin-example","dockerfile","github-actions","kotlin"],"created_at":"2024-11-16T21:10:47.234Z","updated_at":"2025-05-10T15:30:23.779Z","avatar_url":"https://github.com/leoli0605.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android App Development with Kotlin\r\n\r\n本指南將帶領你完成使用 Kotlin 進行 Android 應用開發的基本流程，包括構建應用、生成密鑰庫、簽名應用、驗證簽名，以及對 APK 進行對齊的步驟。\r\n\r\n## 開始之前\r\n\r\n確保你的 Gradle 包裝器 (`gradlew`) 是可執行的。你可以使用以下指令透過 `Docker` 來建置環境。\r\n\r\n```sh\r\ndocker build -t android-kotlin .\r\ndocker run -it --rm -v $(pwd):/app -w /app android-kotlin /bin/bash\r\n```\r\n\r\n或是直接執行 `./dockershell` 來進入容器。\r\n\r\n然後構建整個項目，包括 Debug 和 Release 版本。\r\n\r\n```sh\r\nchmod +x gradlew\r\n./gradlew build\r\n./gradlew assembleDebug\r\n./gradlew assembleRelease\r\n```\r\n\r\n## 生成密鑰庫\r\n\r\n使用 `keytool` 生成密鑰庫和密鑰。\r\n\r\n```sh\r\nkeytool -genkeypair -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000\r\n```\r\n\r\n`-genkeypair` 表示生成一對公鑰和私鑰。`-v` 表示詳細模式。`-keystore my-release-key.keystore` 表示生成的密鑰庫的名稱。`-alias my-key-alias` 表示生成的密鑰的別名。`-keyalg RSA` 表示使用 RSA 算法生成密鑰。`-keysize 2048` 表示生成的密鑰的大小。`-validity 10000` 表示密鑰的有效期為 10000 天。\r\n\r\n以下命令示例展示了如何提供 Distinguished Name (DN) 信息。\r\n\r\n```sh\r\nkeytool -genkeypair -v \\\r\n        -keystore my-release-key.keystore \\\r\n        -alias my-key-alias \\\r\n        -keyalg RSA \\\r\n        -keysize 2048 \\\r\n        -validity 10000 \\\r\n        -storepass \u003c密鑰庫密碼\u003e \\\r\n        -keypass \u003c密鑰密碼\u003e \\\r\n        -dname \"CN=\u003c你的名字\u003e, OU=\u003c你的組織單位\u003e, O=\u003c你的組織\u003e, L=\u003c你的城市\u003e, S=\u003c你的州或省\u003e, C=\u003c你的國家代碼\u003e\"\r\n```\r\n\r\n將 `\u003c密鑰庫密碼\u003e`、`\u003c密鑰密碼\u003e`、`\u003c你的名字\u003e`、`\u003c你的組織單位\u003e`、`\u003c你的組織\u003e`、`\u003c你的城市\u003e`、`\u003c你的州或省\u003e` 和 `\u003c你的國家代碼\u003e` 替換成你的實際資訊。\r\n\r\n## 簽名你的應用\r\n\r\n使用 `jarsigner` 為你的應用簽名。\r\n\r\n```sh\r\njarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore my-release-key.keystore app/build/outputs/apk/release/app-release.apk my-key-alias\r\n```\r\n\r\n記得替換 `\u003c密鑰庫密碼\u003e` 和 `\u003c密鑰密碼\u003e` 為你的實際密碼。\r\n\r\n## 驗證你的應用\r\n\r\n確保你的應用已經被正確簽名。\r\n\r\n```sh\r\njarsigner -verify -verbose -certs app/build/outputs/apk/release/app-release.apk\r\n```\r\n\r\n## 對齊你的應用\r\n\r\n使用 `zipalign` 工具優化 APK，提高應用的運行效率。\r\n\r\n```sh\r\nzipalign -v 4 app/build/outputs/apk/release/app-release.apk app-release-aligned.apk\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoliu0605%2Fgithub-actions-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoliu0605%2Fgithub-actions-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoliu0605%2Fgithub-actions-kotlin/lists"}