You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何更新已发布至Maven Central的Android库?

How to Update Your Android Library on Maven Central

Hey there! Since you’ve already successfully published your Android library to Maven Central before, updating it is just a simplified repeat of those initial steps. Here’s a step-by-step breakdown tailored to your workflow:

Step 1: Update Your Library Version Number

First, you need to increment your library’s version to a unique value (Maven Central doesn’t allow overwriting existing versions). Head to your module’s build.gradle (or build.gradle.kts) file and update the versionName field. For example:

// Old version
versionName "1.0.0"

// Updated version (follow semantic versioning for clarity)
versionName "1.0.1" // bug fix update
// OR
versionName "1.1.0" // feature update

Make sure this version hasn’t been used before—double-check Maven Central if you’re unsure.

Step 2: Finalize and Test Your Updated Code

Before uploading, confirm all your code changes (bug fixes, new features, etc.) are complete, tested, and free of compilation errors. Sync your Gradle project to ensure everything is in order.

Step 3: Upload the Updated Library Using Gradle

Run the same uploadArchives Gradle task you used for your initial publish. You can do this via:

  • Android Studio’s Gradle sidebar: Navigate to your library module > Tasks > upload > uploadArchives
  • Command line: Execute ./gradlew :your-library-module:uploadArchives (replace your-library-module with your actual module name)

If you’ve migrated to newer Android Gradle Plugin (AGP) versions (7.0+), you might be using the publish task instead—run ./gradlew :your-library-module:publish in that case.

Step 4: Close and Release the New Version in Nexus Repository Manager

  1. Log in to the Sonatype Nexus Repository Manager using your existing account.
  2. Navigate to the Staging Repositories section—you’ll see a new entry for your updated library version.
  3. Select the new staging repository and click Close. This triggers Maven Central’s validation checks (e.g., verifying signatures, valid POM files). Wait for the validation to complete (this might take a few minutes).
  4. Once the close operation succeeds, select the repository again and click Release. This pushes your updated library to Maven Central.

Step 5: Wait for Synchronization

Just like your initial publish, it can take a few hours for the updated version to appear in Maven Central’s search index and be available for users to pull into their projects.

Quick Notes to Avoid Issues

  • Ensure you’re using the same groupId and artifactId as your original library—changing these would create a new separate library instead of updating the existing one.
  • Keep your signing configuration intact—Maven Central requires signed artifacts, so if your keystore or signing setup has changed, update your Gradle config accordingly before uploading.
  • Stick to semantic versioning (SemVer) to help users understand the scope of your update (patch, minor, major changes).

内容的提问来源于stack exchange,提问作者Rachit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 11:02:39