【问题标题】:Pdf Viewer implementation causes Gradle project sync is failedPdf Viewer 实现导致 Gradle 项目同步失败
【发布时间】:2018-05-30 10:00:08
【问题描述】:

我在 Android Studio 2.3.3 上创建了一个项目并添加了 pdf 查看器,如下所示:

compile 'com.github.barteksc:android-pdf-viewer:2.0.3'

我可以无错误地构建项目,并且可以显示 pdf 文件。

现在我正在尝试将此库添加到我在 Android Studio 3.0.1 上创建的新项目中,如下所示,Gradle 项目同步失败。

implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'

我收到此错误;

错误:无法解析 ':app@debug/compileClasspath' 的依赖关系: 无法解析 com.github.barteksc:android-pdf-viewer:2.0.3。

我的 gradle.build;

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "test.com.pdfviewer"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.github.barteksc:android-pdf-viewer:2.0.3'
}

【问题讨论】:

    标签: android android-studio pdf pdf-viewer


    【解决方案1】:

    错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析com.github.barteksc:android-pdf-viewer:2.0.3

    ANS:您应该使用最新版本的依赖项

    使用这个

    compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.4'
    

    或者如果你想使用更稳定的版本:

    compile 'com.github.barteksc:android-pdf-viewer:2.8.2'
    

    不是这个

    compile 'com.github.barteksc:android-pdf-viewer:2.0.3'
    

    更多信息请查看com.github.barteksc:android-pdf-viewer的文档

    【讨论】:

    • 我创建了一个新项目并添加了compile 'com.github.barteksc:android-pdf-viewer:2.8.2' 它给了我同样的错误。它可能与我的gradle有关吗? classpath 'com.android.tools.build:gradle:3.0.1'
    • @james 测试用例试试这个buildToolsVersion "26.0.0"
    • Warning:The specified Android SDK Build Tools version (26.0.0) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1. Android SDK Build Tools 26.0.2 will be used. To suppress this warning, remove "buildToolsVersion '26.0.0'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
    • 在收到此警告后我将其更改为 26.0.2 但再次失败
    【解决方案2】:

    好吧,我在 Android Studio 版本 3.0.1 中设置了您在最后提到的确切内容,并实现了 'com.github.barteksc:android-pdf-viewer:2.0.3' 并且工作正常,没有任何问题。

    其他做一件事转到文件>使缓存无效/重新启动,然后尝试打开同一个项目。

    【讨论】:

      【解决方案3】:

      如何修复错误:

      无法解决依赖关系 ':app@debugAndroidTest/compileClasspath': 无法解析 com.github.barteksc:android-pdf-viewer:2.8.2.

      【讨论】:

        【解决方案4】:

        转到设置然后 Gradle 然后取消单击脱机工作框。它在我的 android studio 3.0 中运行良好

        【讨论】:

          猜你喜欢
          • 2015-06-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-12-11
          相关资源
          最近更新 更多