Skip to content

Unable to resolve com.github.barteksc:android-pdf-viewer dependency from JitPack, 2.8.2 and 3.2.0-beta.1 #1252

@dportabella

Description

@dportabella

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:

  1. Added the JitPack repository to settings.gradle.kts:
    I've configured the dependencyResolutionManagement block in settings.gradle.kts to include the JitPack repository.

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url = uri("https://jitpack.io") }
        }
    }
  2. Added the dependency to app/build.gradle.kts:
    I've added the library to the dependencies block in the app-level build.gradle.kts file. I have tried multiple versions, including:

    • 2.8.2
    • 3.2.0-beta.1
    • 3.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

  1. settings.gradle.kts: Added the JitPack repository.

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url = uri("https://jitpack.io") }
        }
    }
  2. 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

  1. app/src/main/res/layout/activity_pdf_viewer.xml: The layout contains the PDFView.

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
  2. 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()
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions