Android failed to resolve dependency

Android studio — gradle failed to resolve dependencies

I have installed Android Studio version 2.1.2 in my system and if I add any dependencies in the Gradle file then I get failed to resolve error .

So I tried to add proxy setting in gradle.properties file

but I get the following error:

How to resolve this issue, please help on that.

7 Answers 7

You need to add a section allprojects at the end of your main build.gradle that defines the repositories for the modules of your project:

and this is the build.gradle (project)

You should update your Android Repository do to it:
1.Open SDK Manager
2.Android Support Repository
3.Install packages

I am under closed network, it does not allow to get Gradle library get downloaded

If you’re on a completely closed network (no internet access at all), it’s common to have a central in-house repository for dependencies, within the local network, where all internal users can get dependencies from. This local repository needs to replicate everything that you would download from external sites/repositories. For example, you must have got your Android Studio install and Android SDK dependencies from somewhere. Also, the Android SDK regularly receives updates — do you see updates when you run the Android SDK manager?

Источник

Unable to resolve all dependencies in android studio [duplicate]

I am getting these errors:-

Error:Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve com.android.support:appcompat-v7:27.0.0.

Error:Unable to resolve dependency for ‘:app@debugAndroidTest/compileClasspath’: Could not resolve com.android.support.test:runner:1.0.1.

Error:Unable to resolve dependency for ‘:app@releaseUnitTest/compileClasspath’: Could not resolve junit:junit:4.12.

Error:Unable to resolve dependency for ‘:app@debugAndroidTest/compileClasspath’: Could not resolve com.android.support.test.espresso:espresso-core:3.0.1.

  1. I have tried many methods but, it is not syncing gradle.
  2. I have tried GRADLE OFFLINE METHOD TOO, BUT THAT ALSO DIDN’T WORK.
  3. I have tried adding GOOGLE MAVEN REPO REPOSITORY BUT THAT DIDN’T WORK.
  4. I have tried all these methods listed here :- Failed to resolve: com.android.support:cardview-v7:26.0.0 android

screenshots where the sync is stuck

I am new to android studio plz omit mistakes.

Источник

Unable to resolve dependency Android Studio 3.0

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)

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

Читайте также:  Developer android sdk installing index

Screenshot

11 Answers 11

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

EDIT —

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

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

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

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:

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

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

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

and the according repository to add is:

Gradle not being in offline mode, is being assumed.

I solve this problem by clearing this directory:

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.

Источник

Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve

Newly installed Android studio 3.1.3 is giving strange dependencies error when making a new project and compiling for very first time.

A similar question that didn’t help resolve the problem.

Event Logs:

ScreenShot:

this problem happened to me several times and forcing https or http didn’t resolve it either

23 Answers 23

You might be importing Application instead of Module. Well you can change it in module’s gradle also.

You also need to remove applicationId from the gradle.

I just figured out how to remove this gradle error, follow the following steps.

  1. Go to «File».
  2. Click on Invalidate Cache/ Restart.
  3. Again click on Invalidate Cache / Restart(On dialoge window).
Читайте также:  Nomedia file on android

Let the gradle build without any interruption.

Thank You! Regards, hope this will help.

I think the problems comes from the following: The internet connection with u was unavailable so Android Studio asked you to enable the «offline work» and you just enabled it

  • File
  • Settings
  • Build, Execution, Deployment
  • Gradle
  • Uncheck offline work

why might unchecking the offline work solves the problem, because in the Gradle sometimes some dependencies need to update (the ones containing ‘+’), so internet connection is needed.

  1. Try «File»->»Invalidate Caches / Restart . «
  2. Try to clean up your .gradle and .idea directory under your project root directory.

Try to add Google Maven repository and sync project

If you are using Android Gradle Plugin 3.1.3, you should be sure that your gradle wrapper version is 4.4. Under the root directory of your project, find gradle-wrapper.properties and modify it as below.

I had this issue with offline mode enable. I disabled offline mode and synced.

  • Open the Preferences, by clicking File > Settings .
  • In the left pane, click Build, Execution, Deployment > Gradle .
  • Uncheck the Offline work .
  • Apply changes and sync project again.

I know its very late but I think it may help someone in resolving his issue.

In my case It was occurring because compileSdkVersion and targetSdkVersion was set to 29 while when I check my SDK Manager, It was showing that package is partially installed. Whereas SDK version 28 was completely installed. I changed my compileSdkVersion and targetSdkVersion to 28 along with support libraries.

Earlier: compileSdkVersion 29 targetSdkVersion 29 implementation ‘com.android.support:appcompat-v7:29.+’ implementation ‘com.android.support:design:29.+’

After Modification: compileSdkVersion 28 targetSdkVersion 28 implementation ‘com.android.support:appcompat-v7:28.+’ implementation ‘com.android.support:design:28.+’

It worked like a charm after applying these changes.

@shizhen answer not worked my case.

Spend more than one day and finally got a working solution. I Was in office environment so by trying different methods my gradle file get corrupted. So I removed all proxy and port info form from following file and things got worked.

User -> .gradle -> gradle.properties

Additionally I enabled «Auto-detect proxy settings» under Android studio -> preferences -> HTTP proxy for network and studio will auto detect network config.

I’m just sharing this answer because I had similar problem.

In the end, error was caused because I inadvertently changed the fileTree . In my case, I fixed by changing:

I have resolved this Gradle caching issue like below.

In case anyone using MacBook then below is the steps I used to resolve this issue.

  1. There is a hidden Gradle folder. By using the below command we can open the hidden Gradle folder and remove the file called gradle.properties

shortcut (⌘ + shift + G) then enter this inside popup window

/.gradle/ press enter

file to be removed -> gradle.properties

  1. Then go back to the android studio and sync your project with Gradle files.

One possibility I have not seen mentioned. If the project you are importing uses android product flavors, you may have a mistake in your missingDimenstionStrategy .

In your :app build.gradle (the one code that is failing to resolve the dependency), ensure you have correctly set the specific flavor of the product that you are depending on. This allows all your later dependency code (e..g implementation , api , etc) to know which precise build it depends on

FOR ANYONE GETTING THIS WHEN TRYING TO IMPORT THEIR OWN CREATED LIBRARIES

I have been playing with Kotlin Multiplatform libraries and was trying to publish my libraries using jitpack and then pulling them into other projects. I’m new to most of this and didn’t know I needed to add publishLibraryVariants to my android configuration in gradle. I followed other tutorials that didn’t require this, so I’m not sure what it is about Kotlin MPP that makes you need it. This is the code though. You could likely publish other variants that met your needs, but these appear to be the standard requirements to build with a basic project. The () after android aren’t absolutely necessary, but the default script comes with them so I left it. The code is essentially the same for Kotlin or Groovy DSL.

In the gradle script for the library being published

Источник

Gradle sync failed due to «Unable to resolve dependency» error

I suddenly get this error and I don’t know how to resolve this. I already tried all suggestions here Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve but nothing worked for me.

What I already tried:

  • updated my sourceCompatibility and targetCompatibility from 1.7 to JavaVersion.VERSION_1_8 as it was suggested to me
  • Deleted the .idea folder
  • deleted google-services plugin, implementation ‘com.google.android.gms:play-services-auth:17.0.0’ in .gradle (app) and google services class path in .gradle (project) —> error still occurs
  • When I update the google-services class path in the project file to the newest version 4.3.2 I get this error
  • deleted the google-services.json and downloaded a new one
  • I invalidated Cache/restart
  • In the SDK manager the Android SDK is displayed as partially installed —> click on show Package details —> nothing to install, everything is shown as installed
  • in the misc.xml file the language level has been updated from JDK 1_7 to 1_8

Here is maybe also a problem I am facing right now which can be cause of this problem:

Previously I had the SDK 29 installed but in the SDK manager it was shown as «partially installed» but when I clicked on «Show package details» there was nothing to install. I wanted to reinstall Android 10 so I deleted it first but now I am unable to reinstall it again because it is not shown anymore in der Android SDK manager. Where can I find it again?

Under SDK Platforms there are only the installed SDKs not all SDKs I can install, is this the right behavior?

Also under «SDK Updates Sites» I get an error with the «Android Repository» under «Enabled» —> red sign with the message «IO exception while downloading manifest»

Here is the problem I currently get in Android Studio:

Источник

Читайте также:  Кпк сталкер для андроид
Оцените статью