라이브러리를 빌드할 때 새 메타데이터가 필요한 위치에 컴파일 오류가 발생하므로 Record() 유형 객체가 인스턴스화될 때마다 필요한 메타데이터 변경사항을 구현해야 합니다. 이렇게 하면 이전이 완료됩니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Metadata requirements\n\n\u003e This guide is compatible with Health Connect version [1.1.0-alpha12](/jetpack/androidx/releases/health-connect#1.1.0-alpha12).\n\nThere are changes to metadata in Health Connect for\ndevelopers who choose to upgrade to release 1.1.0-alpha12.\n| **Warning:** Updating Jetpack versions without implementing these changes will break your Health Connect integration.\n\nLibrary information\n-------------------\n\nThe [Google Maven Android gradle plugin](/build/dependencies#google-maven) artifact ID\nidentifies the Health Connect library to which you will need to upgrade.\nAdd this Health Connect SDK dependency to your module-level\n`build.gradle` file: \n\n dependencies {\n implementation \"androidx.health.connect:connect-client:1.1.0-alpha12\"\n }\n\nMetadata changes\n----------------\n\nTwo metadata changes have been introduced to the **Health Connect Jetpack SDK**\nas of version 1.1.0-alpha12 to ensure that additional useful metadata\nexists in the ecosystem.\n\nYou are required to specify metadata details whenever\na `Record()` type object is instantiated.\n\nYou must specify one of four recording methods\nwhen writing data to **Health Connect**:\n\n| Recording method | Description |\n|-------------------------------------------|---------------------------------------------------------------------------|\n| `RECORDING_METHOD_UNKNOWN` | The recording method cannot be verified. |\n| `RECORDING_METHOD_MANUAL_ENTRY` | The user entered the data. |\n| `RECORDING_METHOD_AUTOMATICALLY_RECORDED` | A device or sensor recorded the data. |\n| `RECORDING_METHOD_ACTIVELY_RECORDED` | The user initiated the start or end of the recording session on a device. |\n\nFor example: \n\n StepsRecord(\n startTime \\= Instant.ofEpochMilli(1234L),\n startZoneOffset \\= null,\n endTime \\= Instant.ofEpochMilli(1236L),\n endZoneOffset \\= null,\n metadata \\= Metadata.manualEntry(),\n Count \\= 10,\n )\n\nYou are required to specify a device type for all\nautomatically and actively recorded data. Current device types include:\n\n| Device type | Description |\n|----------------------|-------------------------------------------|\n| `TYPE_UNKNOWN` | The device type is unknown. |\n| `TYPE_WATCH` | The device type is a watch. |\n| `TYPE_PHONE` | The device type is a phone. |\n| `TYPE_SCALE` | The device type is a scale. |\n| `TYPE_RING` | The device type is a ring. |\n| `TYPE_HEAD_MOUNTED` | The device type is a head-mounted device. |\n| `TYPE_FITNESS_BAND` | The device type is a fitness band. |\n| `TYPE_CHEST_STRAP` | The device type is a chest strap. |\n| `TYPE_SMART_DISPLAY` | The device type is a smart display. |\n\nFor example:\n\n`private val TEST_DEVICE = Device(type = Device.TYPE_PHONE)`\n\n### Snippets updated\n\nHealth Connect guides have been updated wherever new snippets are needed\nto adhere to the new metadata requirements. For some examples, refer to the\n[Write Data](/health-and-fitness/guides/health-connect/develop/write-data) page.\n\n### New metadata methods\n\nMetadata can no longer be directly instantiated, so use one of the\nfactory methods to get a new instance of metadata.\nEach function has three signature variants:\n\n- `activelyRecorded`\n\n - `fun activelyRecorded(device: Device): Metadata.`\n - `fun activelyRecorded(clientRecordId: String, clientRecordVersion: Long = 0, device: Device): Metadata`\n - `fun activelyRecordedWithId(id: String, device: Device): Metadata`\n- `autoRecorded`\n\n - `fun autoRecorded(device: Device): Metadata`\n - `fun autoRecorded(clientRecordId: String, clientRecordVersion: Long = 0, device: Device): Metadata`\n - `fun autoRecordedWithId(id: String, device: Device): Metadata`\n- `manualEntry`\n\n - `fun manualEntry(device: Device? = null): Metadata`\n - `fun manualEntry(clientRecordId: String, clientRecordVersion: Long = 0, device: Device? = null): Metadata`\n - `fun manualEntryWithId(id: String, device: Device? = null): Metadata`\n- `unknownRecordingMethod`\n\n - `fun unknownRecordingMethod(device: Device? = null): Metadata`\n - `fun unknownRecordingMethod(clientRecordId: String, clientRecordVersion: Long = 0, device: Device? = null): Metadata`\n - `fun unknownRecordingMethodWithId(id: String, device: Device? = null): Metadata`\n\nFor more information, see the [Android Open Source Project](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:health/connect/connect-client/src/main/java/androidx/health/connect/client/records/metadata/Metadata.kt).\n\n### Testing data\n\nUse the [Testing Library](/health-and-fitness/guides/health-connect/test/unit-tests) to mock expected metadata\nvalues: \n\n private val TEST_METADATA =\n Metadata.unknownRecordingMethod(\n clientRecordId = \"clientId\",\n clientRecordVersion = 1L,\n device = Device(type = Device.TYPE_UNKNOWN),\n ).populatedWithTestValues(id = \"test\")\n\nThis simulates the behavior of the Health Connect implementation,\nwhich automatically populates these values during record insertion.\n\nFor the testing library, you need to add this Health Connect SDK dependency to\nyour module-level `build.gradle` file: \n\n dependencies {\n testImplementation \"androidx.health.connect:connect-testing:1.0.0-alpha02\"\n }\n\nUpgrade the library\n-------------------\n\nThe main steps you need to perform are:\n\n1. Upgrade your library to 1.1.0-alpha12.\n\n2. When building the library, compilation errors will be thrown where\n new metadata is needed, so be sure to implement the necessary metadata changes\n whenever a `Record()` type object is instantiated. This\n should complete the migration."]]