2016-11-30 86 views
4

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:25.0.1 & Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.0错误:(26,13)无法解析:com.android.support:appcompat-v7:25.0.1

这里是我的gradle这个文件

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.1" 
    defaultConfig { 
     applicationId "com.example.jignesh.myapplication" 
     minSdkVersion 25 
     targetSdkVersion 25 
     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.0', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.0.1' 
    testCompile 'junit:junit:4.12' 
} 
+0

您最近是否重构过任何'xml'文件? –

+0

没有它的新项目&我只是更新android工作室和安装7.0和7.0.1 @Gidi Sprintzin – user2599329

回答

0

您所使用的咖啡版本过时。 。您需要添加以下版本 -

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
androidTestCompile 'com.android.support.test:runner:0.5' 

请查看他们的文档 - Espresso Docs

0

下面的行添加到您的build.gradle

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2'){ 
    exclude module: 'support-annotations' 
    exclude module: 'support-v4' 
    exclude module: 'support-v13' 
    exclude module: 'recyclerview-v7' 
    exclude module: 'appcompat-v7' 
} 

解决此问题的另一种方法。

configurations.all { 
    resolutionStrategy { 
     force 'com.android.support:support-annotations:23.0.1' 
    } 
} 

希望这能解决您的问题。

+0

一个错误解决你的解决方案,但第二个错误:(27,13)未能解决:com.android.support:appcompat-v7 :25.0.1 @jaydroider – user2599329

+0

@ user2599329检查我更新的答案并应用。 –

+0

这个错误用unpated answer没有解决错误:(27,13)无法解析:com.android.support:appcompat-v7:25.0.1 @jaydroider – user2599329

0

取下SDK管理器的所有SDK和SDK工具,并重新安装

1

在Android Studio中,工具 - > android-> SDK管理器 - > SDK工具 - > 更新支持Android库转41

0

打开SDK管理器 - >外观&行为 - >系统设置 - > Android SDK

下载所有需要的平台。

由于

0

解决的问题在上的gradle评论一些线

依赖性{

//编译文件树(DIR: '库',包括:[ '的* .jar'])

// androidTestCompile( 'com.android.support.alert_dialog.espresso:浓咖啡核:2.2.2',{

//排除组: 'com.android.support',模块:“支持 - 注释

//})

compile 'com.android.support:appcompat-v7:26.+' 
compile 'com.android.support:design:26.+' 
compile 'com.android.support.constraint:constraint-layout:1.0.2' 

// testCompile '的JUnit:JUnit的:4.12' }

1

老实说,我不明白这是为什么不会自动照顾您创建时新项目...... 解决方案是增加

maven { 
      url "https://maven.google.com" 
     } 

下allprojects =>在项目层面建立信息库。gradle这个

1

你必须在你的gradle项目文件也使用Maven仓库 -

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

和同步你的项目,它的工作:-)

0

你可以使用:

maven { 
     url "https://maven.google.com" 
    } 

它会解决问题,但我不认为它是最有效的方法,因为当你这样做时,你可能会在你的activity.xml页面上得到渲染错误或警告,你不想冒这个风险。

另一种方式来解决这个问题是去

工具==>的外观和行为==>系统设置==> Android SDK中==> SDK平台和勾去掉上面的Android 7.0(牛轧糖上市的所有Android版本)。

关闭android studio并重新启动您的项目。

我使用的是android 2.2,并没有升级到最新版本,所以这个解决方案可能会不同,不适用于其他android studio版本。

我希望这会有所帮助。

欢呼声

相关问题