Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find com.android.support:appcompat-v7:24.2.1

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.

like image 915
Nguyen Hoang Giang Avatar asked Jan 23 '17 07:01

Nguyen Hoang Giang


4 Answers

Follow these steps:

  1. 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'
  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

enter image description here

enter image description here

like image 186
mehrdad eilbeygi Avatar answered Nov 06 '22 00:11

mehrdad eilbeygi


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
}
like image 31
Noor Hossain Avatar answered Nov 05 '22 23:11

Noor Hossain


Update your android studio to the latest version.

like image 5
Mahesh Sharma Avatar answered Nov 06 '22 01:11

Mahesh Sharma


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'
like image 4
Charitha Ratnayake Avatar answered Nov 06 '22 00:11

Charitha Ratnayake