Studio默认项目失败

Studio默认项目失败

本文介绍了Android Studio默认项目失败:错误:无法解决:com.android.support:support-v4:25.2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上只是第一次开始应用程序开发,而当我创建一个新项目时,默认项目将无法构建.我尝试在Google和SO上查找这些错误,并发现了一些错误,但它们的解决方案不起作用.鉴于我根本没有编辑文件,因此我认为这是Android Studio设置不正确但无法解决的问题.错误如下:

I am literally just starting app development for the first time and the default project when I create a new one will not build. I have tried looking on Google and SO for these errors and have found some but their solutions do not work. Given that I have not edited the files at all, I presume it is an issue with Android Studio not being setup properly but can't figure it out. The errors are as follows:

Error:Failed to resolve: com.android.support:support-v4:25.2.0
Install Repository and sync project
Open File
Show in Project Structure dialog

Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Install Repository and sync project
Show in File
Show in Project Structure dialog

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.+
Install Repository and sync project
Show in File
Show in Project Structure dialog

它指向的build.gradle文件如下:

The build.gradle file it points to is as follows:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.extremecomputing.spotzz"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.google.android.gms:play-services-maps:11.0.1'
    testCompile 'junit:junit:4.12'
}

我尝试过一个以前的项目,该项目创建了一些我在网上找到的东西.如他们所建议的版本中的+可能会导致无法预测的构建,但事实并非如此.一个人在dependencies部分中推荐了几行编译行,它暂时更改了错误,说我需要下载某些内容,然后我又恢复了原来的错误.我还尝试确保SDK工具已更新,并且看起来确实如此.任何建议将不胜感激.

I have tried with a previous project that I had created a few things I found online. Such as they had recommended the + in the version could cause unpredictable builds, but that wasn't it. One had recommended a few compile lines in the dependencies section, it changed the errors for a moment saying I needed to download something, I did then it went back to the original errors. I also have tried to make sure that the SDK tools are updated, and they appear to be. Any suggestions would be greatly appreciated.

推荐答案

尝试一下:

  1. 在Android Studio中,打开工具"->"Android"->"SDK管理器"
  2. 在"SDK工具"标签下,取消选中导致问题的库
  3. 单击应用"将其卸载
  4. 重新检查相同的库,单击应用"以重新安装它们
  5. 关闭SDK Manager并运行Gradle同步/构建

这篇关于Android Studio默认项目失败:错误:无法解决:com.android.support:support-v4:25.2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 00:18