This patch is built on the official androidx.lifecycle version 2.8.0 to support OpenHarmony platform.
Add the remote repository in your project's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://mirrors.tencent.com/nexus/repository/maven-tencent/")
}
}
}Add the following dependencies in your commonMain module's build.gradle.kts:
implementation("androidx.lifecycle:lifecycle-common:2.8.0-KBA-002")
implementation("androidx.lifecycle:lifecycle-runtime:2.8.0-KBA-002")
implementation("androidx.lifecycle:lifecycle-viewmodel:2.8.0-KBA-002")Clone the Google AOSP support project:
git clone https://android.googlesource.com/platform/frameworks/supportCheckout the specific commit:
git checkout 7ad6b8bbf8fa3d5a3c97feca6c52a1a2bf98a622Download ov-androidx.lifecycle-2.8.0.patch and apply it:
git apply ov-androidx.lifecycle-2.8.0.patchAdd remote maven repositories in buildSrc/repos.gradle:
handler.maven {
url = "https://mirrors.tencent.com/nexus/repository/maven-public"
}
handler.maven {
url = "https://mirrors.tencent.com/nexus/repository/maven-tencent"
}Configure maven publish settings in playground-common/androidx-shared.properties:
maven.remote.url=https://your-maven-repo-url
maven.remote.username=your_username
maven.remote.password=your_passwordUpdate the lifecycle version in libraryversions.toml:
LIFECYCLE=XXXRequirements: JDK 21
Navigate to the project root and run:
cd playground-projects/lifecycle-playground
./gradlew publish --dependency-verification=offAfter syncing, run the publishing gradle task in Android Studio to deploy the lifecycle artifacts.