-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
I am attempting to add the com.github.barteksc:android-pdf-viewer library to an Android project, but Gradle is unable to resolve the dependency.
What I've Tried:
-
Added the JitPack repository to
settings.gradle.kts:
I've configured thedependencyResolutionManagementblock insettings.gradle.ktsto include the JitPack repository.dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url = uri("https://jitpack.io") } } } -
Added the dependency to
app/build.gradle.kts:
I've added the library to thedependenciesblock in the app-levelbuild.gradle.ktsfile. I have tried multiple versions, including:2.8.23.2.0-beta.13.2.0-beta.3
dependencies { // ... other dependencies implementation("com.github.barteksc:android-pdf-viewer:VERSION") // Where VERSION is one of the versions above }
The Problem with Each Attempt:
Regardless of the version used, the Gradle build fails with a "Could not resolve all files for configuration" error. The build output confirms that Gradle is searching for the artifact in the correct JitPack repository URL but is unable to find it.
Here is a snippet of the error message:
> Could not find com.github.barteksc:android-pdf-viewer:VERSION.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/...
- https://repo.maven.apache.org/maven2/...
- https://jitpack.io/com/github/barteksc/android-pdf-viewer/VERSION/...
This suggests a potential issue with how the library is published on JitPack or a problem with the JitPack repository itself.
Context
Here it is my code and configuration for a PDF viewer app. The app is failing to build due to a dependency resolution issue with com.github.barteksc:android-pdf-viewer.
Gradle Configuration
-
settings.gradle.kts: Added the JitPack repository.dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url = uri("https://jitpack.io") } } } -
app/build.gradle.kts: Added the dependency for the PDF viewer.dependencies { // ... implementation("com.github.barteksc:android-pdf-viewer:3.2.0-beta.3") // Also tried 2.8.2 and 3.2.0-beta.1 }
Android Manifest
app/src/main/AndroidManifest.xml: An intent filter was added to a new PdfViewerActivity to handle ACTION_VIEW for PDF files.
<activity
android:name=".PdfViewerActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
</activity>Layout and Activity
-
app/src/main/res/layout/activity_pdf_viewer.xml: The layout contains thePDFView.<com.github.barteksc.pdfviewer.PDFView android:id="@+id/pdfView" android:layout_width="match_parent" android:layout_height="match_parent" />
-
app/src/main/java/com/example/android3/PdfViewerActivity.kt: The activity receives the PDF URI from the intent and displays it.package com.example.android3 import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.github.barteksc.pdfviewer.PDFView import com.example.android3.R class PdfViewerActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_pdf_viewer) val pdfView = findViewById<PDFView>(R.id.pdfView) intent.data?.let { pdfView.fromUri(it).load() } } }