Cannot resolve symbol v7 in importing appcompatactivity

Basel Qarabash picture Basel Qarabash · Apr 17, 2018 · Viewed 10.6k times · Source

I'm new to Android Studio and it was working just fine and I made few apps and they worked pretty well, and then I downloaded a project from GitHub and tried to import it, the project didn't work but now every time I make new project this error happens:(I can't upload pictures)

Import android.support.v7.app.AppCompatActivity; The 'v7' is colored in red and it says it can't resolve symbol v7

In the messages it giving me this:

Unable to resolve dependency for ':app@debug/compileClasspath': could not resolve com.android.support:appcompat-v7:26.0.0-beta1)

I tried the following:

  1. invalidate caches and restart
  2. compile 'com.android.support:appcompat-v7:26.0.0' in the dependencies in the build.gradle
  3. clean project and sync project with Gradle files

But nothing worked.

I have Android studio 3.0.1
Android emulator 27.1.12
Android SDK platform tools 27.0.1
Android SDK tools 26.1.1

Answer

amk picture amk · Apr 17, 2018

To use support libraries starting from version 26.0.0 you need to add Google's Maven repository to your project's build.gradle file as described here: https://developer.android.com/topic/libraries/support-library/setup.html

allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }

For Android Studio 3.0.0 and above:

allprojects {
        repositories {
            jcenter()
            google()
        }
    }