无法解析依赖 Android Studio 3.0 [英] Unable to resolve dependency Android Studio 3.0

查看:36
本文介绍了无法解析依赖 Android Studio 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

拥有更新的 Android Studio 3.0 是件好事.但是我在使用 Android Studio 3.0 时遇到了问题,我刚刚在 Android Studio 3.0 中创建了一个新项目.然后我得到了一些错误

我通过将 dependencies 更改为最新版本并解决了问题来解决这些问题.

但是,当我添加 facebook account-kit sdk com.facebook.android:account-kit-sdk:4.+ 的 dependency代码>

我收到以下错误-:

<块引用>

错误:无法解析:app@debug/compileClasspath"的依赖关系:无法解析 com.facebook.android:account-kit-sdk:4.+.打开文件
显示详细信息

build.gradle(app)

应用插件:'com.android.application'应用插件:'kotlin-android'应用插件:'kotlin-android-extensions'安卓 {compileSdkVersion 26默认配置{applicationId "ultimate.devil.logintest"minSdk 版本 15目标SDK版本26版本代码 1版本名称1.0"testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"}构建类型{释放 {minifyEnabled falseproguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}依赖{实现文件树(目录:'libs',包括:['*.jar'])实现"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"实现 'com.android.support:appcompat-v7:26.1.0'实现 'com.android.support.constraint:constraint-layout:1.0.2'编译'com.facebook.android:account-kit-sdk:4.+'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'}

注意-:

  • 我正在关注

    解决方案

    经过一番研究,我已经解决了这个问题.

    步骤 1-:

    我在设置中禁用了 Gradle 离线工作.

    <块引用>

    文件 > 设置 > 构建、执行、部署 > Gradle > 取消选中离线工作

    第 2 步:

    然后,我只是将 compile 'com.facebook.android:account-kit-sdk:4.+' 更改为 api 'com.facebook.android:account-kit-sdk:4.+'

    我不知道它为什么有效.我在文档中看到 api 参考

    现在可以了:)

    编辑 -

    现在,我可以同时使用 apiimplementation 并且一切正常.

    谢谢,

    It's good to have a Updated Android Studio 3.0. But I am facing a problem with Android Studio 3.0, I just created a new project in Android Studio 3.0. Then I got some error

    I solved these by changing dependencies to latest version and issues solved.

    But, when I added a dependency of facebook account-kit sdk com.facebook.android:account-kit-sdk:4.+

    I am getting following errors-:

    Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.facebook.android:account-kit-sdk:4.+. Open File
    Show Details

    build.gradle(app)

    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    
    android {
        compileSdkVersion 26
        defaultConfig {
            applicationId "ultimate.devil.logintest"
            minSdkVersion 15
            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(dir: 'libs', include: ['*.jar'])
        implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.facebook.android:account-kit-sdk:4.+'
        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'
    }
    

    NOTE -:

    • I am following Facebook Developers Docs

    • I have tried by changing compile to implementation

    • I have also tried changing com.facebook.android:account-kit-sdk:4.+ to com.facebook.android:account-kit-sdk:4.11.0 and com.facebook.android:account-kit-sdk:4.27 by googling latest version of Facebook Account-Kit SDK

    • I have also tries StackOverFlow Answers with possible with same problem. But no one help me

    Screenshot

    解决方案

    After some research I have solved this issue.

    Step 1-:

    I disable the Gradle offline work in settings.

    File > Settings > Build, Execution, Deployment > Gradle > Uncheck Offline Work

    Step 2-:

    Then, I just changed compile 'com.facebook.android:account-kit-sdk:4.+' to api 'com.facebook.android:account-kit-sdk:4.+'

    I don't know exactly why it's work. I see api in docs Reference

    Now it works :)

    EDIT -

    Now, I am able to use both api or implementation and everything works fine.

    Thanks,

    这篇关于无法解析依赖 Android Studio 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆