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:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
Open File
Show Details
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
Open File
Show Details
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
Open File
Show Details
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
Open File
Show Details
Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:28.0.0-alpha3.
Open File
Show Details
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support.constraint:constraint-layout:1.1.2.
Open File
Show Details
ScreenShot:
this problem happened to me several times and forcing https or http didn't resolve it either
You might be importing Application instead of Module. Well you can change it in module's gradle also.
Change
apply plugin: 'com.android.application'
to
apply plugin: 'com.android.library'
You also need to remove applicationId from the gradle.
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
To fix this:
- 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.
I just figured out how to remove this gradle error, follow the following steps.
- Go to "File".
- Click on Invalidate Cache/ Restart.
- Again click on Invalidate Cache / Restart(On dialoge window).
Let the gradle build without any interruption.
Thank You! Regards, hope this will help.
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.
- Try "File"->"Invalidate Caches / Restart ..."
- Try to clean up your
.gradle
and.idea
directory under your project root directory. Try to add Google Maven repository and sync project
buildscript { repositories { jcenter() google() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.1.3' } } allprojects { repositories { google() jcenter() maven { url "https://maven.google.com" } } }
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.distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
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:
// implementation or compile
implementation fileTree(include: ['*.jar'])
to
// implementation or compile
implementation fileTree(include: ['*.jar'], dir: 'libs')
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.
I was unable to find the root cause of the issue but got a workaround. I started by setting my the java home variable as such.
vi ~/.bash_profile
(this is for macs only. bash profiles are different on linux)- type the letter
i
for insert and then set the JAVA_HOME variable as such export JAVA_HOME=/Applications/Android\Studio.app/Contents/jre/jdk/Contents/Home/
- quit the vi editor with
esc
then type:wq
- Restart the computer
- Voila! Your android studio projects should build without any qualms
In my case : When I setup AS, my windows was configured with proxy. Later, I disconnect proxy and disable proxy in AS settings, But, in file .gradle\gradle.properties - proxy - present
Just, in text editor clear proxy settings from this file
I had your issue, i fixed it . this error comes when your target api level is not completely downloaded . you have two ways: go to your SDK menu and download all of the android 9 components or the better way is go to your build.gradle(Module app) and change it like this:But remember, before applying these changes, make sure you have fully downloaded api lvl 8
This can happen if you are using both
'com.android.support:appcompat-v7:28.0.0-alpha3'
'com.android.support:support-v4:28.0.0-alpha3'
Remove the line
implementation 'com.android.support:support-v4:28.0.0-alpha3'
from your build.gradle
file and try again.
来源:https://stackoverflow.com/questions/51218535/unable-to-resolve-dependency-for-appdebug-compileclasspath-could-not-resolv