无法解析:com.github.barteksc:android-pdf-viewer:3.2.0-beta.1 如何修复此问题

8
我试图构建一个 Android PDF 阅读器并添加一个库 com.github.barteksc:android-pdf-viewer:2.8.2,但是它显示以下错误:

我的 build.gradle 文件如下,请帮我修复这个问题,我想尽快构建应用:

请大家帮帮我。

plugins {
    id 'com.android.application'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.dash.songuploader"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildToolsVersion '32.0.0'
}

dependencies {
    implementation 'com.karumi:dexter:6.2.3'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
//    implementation 'com.squareup.picasso:picasso:2.71828'

    //pdf library
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    //dbshbs
    implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'
//    implementation 'com.joanzapata.pdfview:android-pdfview:2.8.2@aar'
}

请确保您没有开启离线模式。 - Sujal Kumar
8个回答

9
许多上面的评论都提到要在settings.gradle中添加jcenter()。
但这对我不起作用。为了让我的Flutter项目再次运行,我必须将jcenter()添加到android/build.gradle文件中。
allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

5
将jcenter()添加到settings.gradle

对于那些不熟悉settings.gradle(像我一样)的人,这应该放在哪个文件中? - Shawn Ashton
设置文件位于 Android 项目的根目录中。 - MisterAnt
完美。它有效。 - Angad Cheema

2
implementation 'com.github.mhiew:android-pdf-viewer:3.2.0-beta.1'

在Android Studio中,我只需将jcenter()替换为mavenCentral(),并使用以下依赖项进行替换。

1

参考图片

这是一张关于IT技术的参考图片。
    dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

将jcenter()添加到settings.gradle

1
对于使用flutter_pdfview包的flutter项目,尝试在build.gradle文件的maven仓库顶部添加jcenter()。
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

1
在Android Studio中,将jcenter()添加到gradle.setting中的以下位置对我在Android Studio中有所帮助。
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
    }

0

maven { url 'https://jitpack.io' } 添加到 settings.gradle(项目设置)中。

像这样:

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    maven { url 'https://jitpack.io' }
}

}


0

对于这个版本2.8.2,它只在jCenter上可用,但如果您在使用jCenter时遇到问题,可以使用其他替代方案,例如jitpack。

maven { url 'https://jitpack.io' }

implementation 'com.github.barteksc:AndroidPdfViewer:master-SNAPSHOT'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接