{"id":17061235,"url":"https://github.com/kunminx/keyvaluex","last_synced_at":"2026-03-06T08:32:48.858Z","repository":{"id":46557112,"uuid":"515393066","full_name":"KunMinX/KeyValueX","owner":"KunMinX","description":"消除 Android 项目 Key-Value 样板代码","archived":false,"fork":false,"pushed_at":"2023-07-21T17:44:21.000Z","size":222,"stargazers_count":75,"open_issues_count":3,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T22:31:07.846Z","etag":null,"topics":["android","datastore","key-value","mmkv","sharedpreferences"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KunMinX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2022-07-19T01:22:33.000Z","updated_at":"2024-12-29T16:24:07.000Z","dependencies_parsed_at":"2024-10-27T12:50:50.359Z","dependency_job_id":"f33daff0-6358-4cdd-ae3a-19755791bcb9","html_url":"https://github.com/KunMinX/KeyValueX","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KunMinX%2FKeyValueX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KunMinX%2FKeyValueX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KunMinX%2FKeyValueX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KunMinX%2FKeyValueX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KunMinX","download_url":"https://codeload.github.com/KunMinX/KeyValueX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858016,"owners_count":20359261,"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","datastore","key-value","mmkv","sharedpreferences"],"created_at":"2024-10-14T10:46:27.363Z","updated_at":"2026-03-06T08:32:48.803Z","avatar_url":"https://github.com/KunMinX.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://tva1.sinaimg.cn/large/e6c9d24ely1h4kltojgmqj21h80dmabg.jpg)\n\n\u0026nbsp;\n\n### [🌏 English README](https://github.com/KunMinX/KeyValueX/blob/main/README_EN.md)\n\n\u0026nbsp;\n\n# 特性\n\n1.根据接口配置自动生成，无需手写 key、value、getter、setter、init 样板代码\n\n2.使用注解，但无需初始化 build，对巨型项目友好\n\n3.通过接口路径 MD5 自动完成分组，消除各组件模块配置冲突\n\n4.KeyValueX 默认 SP 读写，可根据 KeyValueTool 自行注入 MMKV、DataStore 等实现（详见 Git MMKVSample 分支，App.java 示例）。\n\n5.支持 Java\n\n\u0026nbsp;\n\n项目根目录 build.gradle 添加如下依赖：\n\n```\nallprojects {\n  repositories {\n    // ...\n    maven { url 'https://www.jitpack.io' }\n  }\n}\n```\n\n模块 build.gradle 添加如下依赖：\n\n\u003e 注意：\n\u003e\n\u003e 1.建议配置在定义 @KeyValueX 接口所在的模块，以免发生 ClassNotFoundException \u0026 ClassCastException 情况\n\u003e\n\u003e 2.如使用 KeyValueProvider 获取 KeyValue 实例，需在项目 proguard-rules.pro 中须配置 @KeyValueX 接口所在目录，避免被混淆，\n\u003e 如欲混淆，勿使用 KeyValueProvider，而是定义完 @KeyValueX 接口后，build 一次，生成 xxxImpl ，并通过 xxxImpl 赋值。\n\n```\nimplementation 'com.github.KunMinX.KeyValueX:keyvalue:3.6.0-beta'\nannotationProcessor 'com.github.KunMinX.KeyValueX:keyvalue-compiler:3.6.0-beta'\n```\n\n\u0026nbsp;\n\n# 使用 2 步曲\n\n1.创建 KeyValueGroup 接口，例如\n\n```java\n@KeyValueX\npublic interface Configs {\n  KeyValueInteger days();\n  KeyValueString accountId();\n  KeyValueSerializable\u003cUser\u003e user();\n}\n```\n\n2.在页面等处通过 get( ) set( ) 方法读写 KeyValue\n\n```java\npublic class MainActivity extends AppCompatActivity {\n  //Configs 不可混淆：\n  //Configs configs = KeyValueProvider.get(Configs.class);\n\n  //Configs 可被混淆：\n  Configs configs = new ConfigImpl();\n  \n  ...\n\n  //写\n  configs.user().set(user);\n\n  //读\n  configs.user().get().title;\n  configs.user().get().content;\n}\n```\n\n\u0026nbsp;\n\n# Thanks\n\n[AndroidCodeUtils - SPUtils](https://github.com/Blankj/AndroidUtilCode/blob/d0b890e106be3658d259ca7ec52e232b991f67f1/lib/utilcode/src/main/java/com/blankj/utilcode/util/SPUtils.java)\n\n\u0026nbsp;\n\n# License\n\n```\nCopyright 2019-present KunMinX\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkunminx%2Fkeyvaluex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkunminx%2Fkeyvaluex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkunminx%2Fkeyvaluex/lists"}