Gradle调用JitPack托管自定义库时出现依赖解析失败问题
Hey there, let’s work through this JitPack dependency problem you’re hitting! That error message tells us JitPack can’t locate the NewInstllSDK-1.0.4.jar file at the expected URL, which usually stems from a build failure on JitPack’s end, or a misconfiguration in your library or project setup. Here’s how to troubleshoot this:
1. Check JitPack’s Build Status for Your Library Version
Head over to your library’s JitPack page tied to your GitHub repo sanjay11MP/NewInstllSDK, find the version tag 1.0.4, and look at the build log. If the build failed, that’s the root cause. Common Android library build failures on JitPack include:
- Missing
maven-publishplugin in your library’s build config - Compilation errors in your library code
- Incorrect group/artifact/version setup in your publish configuration
2. Verify Your Library’s Publish Configuration
Make sure your library module’s build.gradle (or build.gradle.kts) has the necessary setup to generate a publishable artifact. Here’s what you need:
For Groovy build.gradle:
plugins { id 'com.android.library' id 'maven-publish' } android { // Keep your existing Android config (compileSdk, defaultConfig, etc.) } publishing { publications { release(MavenPublication) { from components.release groupId = 'com.github.sanjay11MP' artifactId = 'NewInstllSDK' version = '1.0.4' } } }
For Kotlin DSL build.gradle.kts:
plugins { id("com.android.library") id("maven-publish") } android { // Keep your existing Android config } publishing { publications { create<MavenPublication>("release") { from(components["release"]) groupId = "com.github.sanjay11MP" artifactId = "NewInstllSDK" version = "1.0.4" } } }
After updating this config, push the changes to your GitHub repo, then go back to JitPack and trigger a rebuild for the 1.0.4 version.
3. Double-Check Your Project’s Dependency Setup
Ensure your app module has JitPack added as a repository and the correct dependency line:
Module-level build.gradle (older Android Studio versions):
repositories { mavenCentral() maven { url 'https://jitpack.io' } } dependencies { implementation 'com.github.sanjay11MP:NewInstllSDK:1.0.4' }
settings.gradle (Android Studio Hedgehog+):
If you’re using a newer Android Studio version, repositories should be declared in settings.gradle instead:
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() maven { url 'https://jitpack.io' } } }
4. Confirm Your GitHub Tag Exists and Is Pushed
The version 1.0.4 needs to match a Git tag in your repo. Run git tag locally to check if the tag exists, and if not, create it with git tag 1.0.4 then push it to GitHub with git push origin 1.0.4. If the tag was added after you pushed your code, you’ll need to rebuild the version on JitPack.
5. Clean and Rebuild Your Project
Cached files can sometimes cause resolution issues. In Android Studio:
- Go to
Build > Clean Project - Then
Build > Rebuild Project - If that still doesn’t work, try invalidating caches:
File > Invalidate Caches... > Invalidate and Restart
If you’ve gone through all these steps and the problem persists, share the JitPack build log and your library’s full build.gradle code, and we can dig deeper into the issue!
内容的提问来源于stack exchange,提问作者Sanjay




