Unable to resolve dependency Android Studio 3.0
Asked Answered
A

11

40

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

enter image description here

Avaunt answered 29/10, 2017 at 14:58 Comment(4)
I'm facing the same issue. Any luck?Og
@BasantMatharu found solution see the answer below.Avaunt
Thanks Sir, @Pavneet_Singh.Avaunt
Had the same issue and solved it using this link.Grief
A
74

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

enter image description here

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,

Avaunt answered 30/10, 2017 at 17:35 Comment(3)
you are a life saferControl
@Avaunt can you give me any suggestions in it #50028124Neckpiece
Finding your answer was like: thug lifeNomen
S
6

Add matchingFallbacks = ['release', 'debug'] in the buildType that is failing to compile.

E.g. I was having an error for releaseStaging:

buildTypes {
    debug {
        buildConfigField "String", "CODEPUSH_KEY", '""'
    }
    releaseStaging {
        buildConfigField "String", "CODEPUSH_KEY", 'myKey'
        signingConfig signingConfigs.release
        matchingFallbacks = ['release', 'debug']
    }
    release {
        buildConfigField "String", "CODEPUSH_KEY", 'myKey'
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
Spelt answered 21/11, 2017 at 9:39 Comment(0)
H
4

I am facing similar error day before yesterday. Just solved it here

Moreover, as mentioned in the latest gradle release notes , you should avoid using dynamic dependencies with version number as:

com.facebook.android:account-kit-sdk:4.+

Try to replace it with appropriate version number as 4.0.0 or latest. Hope it solves the problem.

Homophony answered 29/10, 2017 at 15:43 Comment(5)
Thanks for your answer @prdp89. but as you can see in my question. I had mentioned that i had tried by chnging versions of account-kit sdkAvaunt
@UltimateDevil, can we see more descriptive stacktrace of yours?Homophony
unfortunately that's the only stacktrace I am getting in android studio. I have attached screenshot alsoAvaunt
change to full version work for me [implementation 'com.facebook.android:account-kit-sdk:4.34.0']Cruiserweight
meanwhile it's 4.35.0 ...just added an answer with all the build artifacts.Agraffe
B
2

Short story:

Downgrade to Gradle 4.2.1

Long story:

I was using Gradle version 4.3 based on the answer here as that question was my error. After doing that change than I started having your problem.

Downgrading to version 4.2.1 your problem went away. Now I have to go back to the previous problem.

I also had this problem while compiling my project with Android Studio 3.0 and gradle plugin 3.0.0

If I will have other problems I will post here the updates

Boer answered 1/11, 2017 at 12:54 Comment(1)
A
2

all the Facebook Account Kit SDK build artifacts can be found on Maven Central:

// https://mvnrepository.com/artifact/com.facebook.android/account-kit-sdk
api 'com.facebook.android:account-kit-sdk:4.35.0'

and the according repository to add is:

repositories {
    mavenCentral()
}

Gradle not being in offline mode, is being assumed.

Agraffe answered 7/8, 2018 at 17:51 Comment(0)
M
1

I solve this problem by clearing this directory:

c:\Users\User name\\.gradle\caches\
Malacostracan answered 14/2, 2018 at 9:7 Comment(0)
A
1

I had the same issue and I solved it by changing apply plugin: 'com.android.application' to apply plugin: 'com.android.library'

Regarding my issue, it was a little bit different from yours. I have the second module with android library and from android developers page under the section "Convert an app module to a library module". My guess is that it is related to managing Manifest files inside of the architecture, so Android will know where is the main Manifest file.

And regarding api and implementation, the answer can be found here

The api configuration should be used to declare dependencies which are exported by the library API, whereas the implementation configuration should be used to declare dependencies which are internal to the component.

Autotoxin answered 24/2, 2018 at 19:19 Comment(0)
E
0

Had the same issue. After trying everything, finally realized that it was the network that didn't allow syncing dependencies. Tried out with hotspot and it worked.

Ethnogeny answered 9/1, 2018 at 9:28 Comment(0)
A
0

I had the same issue and I did fix it like this :

implementation project(path: 'com.facebook.android:account-kit-sdk:4.+', configuration: 'default')
Airspace answered 5/5, 2019 at 16:17 Comment(0)
S
0

Downgrade these two files solve the problem

project`s build.graddle to 3.1.4 graddle-wrapper properties to 4.4

Shreveport answered 27/8, 2019 at 16:0 Comment(0)
D
0

Saw an old project. It showed "build" successful. So i checked build.gradle file. Comparing those 2 projects i saw a change in dependencies version number. Then i just copied version numbers from the old proj and it worked. There was one more BuildUsing or so in android{} i removed it from my new proj (it was not in my old proj). i think it is because of an incomplete or corrupt gradle update.

Delusion answered 5/7, 2021 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.