I am trying to build an application on my real device using Android Studio but it gives me an error:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not find com.android.support:appcompat-v7:24.2.1 .
Required by:
MyApplication:app:unspecified
The appcompat-v7:24.2.1 is installed and located at ...\sdk\extras\android\m2repository\com\android\support\appcompat-v7\24.2.1.
I also put this directory in the "library repository" in file > project structure but the problem was not solved. Thanks a lot.
Follow these steps:
update version of build tools and dependences in buyild.gradle(Module)
android {
compileSdkVersion 24
buildToolsVersion "24.2.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 24
...
}
and dependences
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
Uses Maven google repository instead of google() in build.gradle(project)
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
.....
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
}
}
Note: Android Studio 4.1.1 Gradle 6.5
I have just used Maven google repository in build.gradle(project) :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Update your android studio to the latest version.
It's better to use android latest versions. But you can resolve by replace below code in your app/build.gradle
file
android {
compileSdkVersion 24
buildToolsVersion "24.2.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 24
...
}
Dependencies as follows:
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With