How To Solve Gradle Error Failed to resolve: com.android.support:appcompat-v7:26.0.0 When Building An Android App
If you are building your Android applications in Android Studio or another IDE, you may come across the following error:
This is happening because there has been a change that requires an update in your code. You used to be able to download the Google support files through the SDK Manager. This is the familiar place where you select all of the items that you want to add and the system will then fetch those items and add them to your setup. Google, however, has now decided that they will not provide support libraries in this way anymore. Google now requires you to go through their Maven repositories to get support files. This means that you will need to modify where Gradle looks for support files. It is very simple to update your project to look in the right place.
Since, Gradle was complaining about not being able to locate the dependency, you don't need to update the dependencies area in the module build.gradle file at this time. Just adding the line for the Maven repository should be enough to get Gradle building your application.
Enjoy!
Kila Morton
Could not resolve all dependencies for configuration ':app:_debugApkCopy'. > Could not find any version that matches com.android.support:appcompat-v7:27.+. Versions that do not match: 26.0.0-alpha1 25.3.1 25.3.0 25.2.0 25.1.1 + 31 more Required by: project :app > Could not find any version that matches com.android.support:design:27.+. Versions that do not match: 26.0.0-alpha1 25.3.1 25.3.0 25.2.0 25.1.1 + 21 more Required by: project :whateverYourProjectAppNameIs
This is happening because there has been a change that requires an update in your code. You used to be able to download the Google support files through the SDK Manager. This is the familiar place where you select all of the items that you want to add and the system will then fetch those items and add them to your setup. Google, however, has now decided that they will not provide support libraries in this way anymore. Google now requires you to go through their Maven repositories to get support files. This means that you will need to modify where Gradle looks for support files. It is very simple to update your project to look in the right place.
- Locate the build.gradle for your PROJECT. NOTE - Make sure you locate your PROJECT build.gradle file and not the build.gradle file for your modules.
- Under jCenter(), add a new item for maven. It should look like this:
allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } }
- Save and build your project now. The error should now be gone and you should be good to go :-).
Since, Gradle was complaining about not being able to locate the dependency, you don't need to update the dependencies area in the module build.gradle file at this time. Just adding the line for the Maven repository should be enough to get Gradle building your application.
Enjoy!
Kila Morton
That worked great, thank you!
ReplyDelete