2017-06-20 71 views
0

我是新来的Android,我的IDE是Android的工作室,在gradle这个同步窗口我看到2个错误:错误与Android Studio中创建应用程序

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

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

我试图从SDK管理器,但不幸的是下载支持库我不能因为我们在伊朗而受到限制。

然后我手动下载了它,并把它添加到我的项目/库/ Android的支持-V7-appcompat.jar和我添加它的依赖线

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 17 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.android.aqil.textview" 
     minSdkVersion 17 
     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' 
     } 
    } 
    productFlavors { 
    } 
} 

allprojects { 
    repositories { 
     //... 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
} 
dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    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:25.3.1' 
    testCompile 'junit:junit:4.12' 
    compile files('support/annotations/android-support-annotations.jar') 
    compile files('support/appcompat/libs/android-support-v4.jar') 
    compile files('support/appcompat/libs/android-support-v7-appcompat.jar') 
    compile files('support/customtabs/libs/android-support-customtabs.jar') 
    compile files('support/design/libs/android-support-design.jar') 
    compile files('support/multidex/library/libs/android-support-multidex.jar') 
    compile files('support/multidex/instrumentation/libs/android-support-multidex-instrumentation.jar') 
    compile files('support/percent/libs/android-support-percent.jar') 
    compile files('support/recommendation/libs/android-support-recommendation.jar') 
    compile files('support/v13/android-support-v13.jar') 
    compile files('support/v14/preference/libs/android-support-v14-preference.jar') 
    compile files('support/v17/leanback/libs/android-support-v17-leanback.jar') 
    compile files('support/v17/preference-leanback/libs/android-support-v17-preference-leanback.jar') 
    compile files('support/v4/android-support-v4.jar') 
    compile files('support/v7/appcompat/libs/android-support-v4.jar') 
    compile files('support/v7/appcompat/libs/android-support-v7-appcompat.jar') 
    compile files('support/v7/cardview/libs/android-support-v7-cardview.jar') 
    compile files('support/v7/gridlayout/libs/android-support-v7-gridlayout.jar') 
    compile files('support/v7/mediarouter/libs/android-support-v7-mediarouter.jar') 
    compile files('support/v7/palette/libs/android-support-v7-palette.jar') 
    compile files('support/v7/preference/libs/android-support-v7-preference.jar') 
    compile files('support/v7/recyclerview/libs/android-support-v7-recyclerview.jar') 
} 

到gradle.build但是,当我尝试建立我的项目,我得到这个错误

Error:A problem occurred configuring project ':app'. 
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'. 
    > Could not find any matches for com.android.support:appcompat-v7:25.+ as no versions of com.android.support:appcompat-v7 are available. 
    Required by: 
     TextView_Programming_API17:app:unspecified 

我使用API​​ 17,我试过19,20,25但错误是一样的。此外,我添加了支持库存储库,但没有工作,问题在哪里?

+0

您可以从您的浏览器此链接? https://jcenter.bintray.com/com/android/support/support-compat/24.2.0/support-compat-24.2.0.aar –

+0

@KamranAhmed我得到这个错误“未找到请求的路径。” –

+0

更新了链接,现在可以吗? –

回答

1

只是尝试使用VPN,u可以使用hotSpotshield应用程序来解决这个限制

+0

我试过,但没有工作,即时通讯使用tor在Linux中,如果你知道任何其他方式来做到这一点,建议我 –

0

从这三条线取下第一线

编译“com.android.support:appcompat-v7:25.+ '

testCompile '的JUnit:JUnit的:4.12'

编译文件(' 库/ Android的支持-V7-appcompat.jar')}

只能使用最后2升INES

testCompile '的JUnit:JUnit的:4.12'

编译文件( '库/ Android的支持-V7-appcompat.jar')}

因为你不能定义相同的文件不止一个时间。 希望这个解决方案有帮助。

+0

谢谢你的回答,但没有工程 –

+0

卸载Android支持库从SDK管理器 再次安装Android支持存储库,然后清理你的项目,并重建它 – 2017-06-20 10:43:17

0

您支持存储库看起来很旧。您需要:

  • 打开SDK管理器通过点击该按钮

SDK Manager Button

  • 切换到SDK工具标签

SDK Tools Tab

  • 检查支持Android库

  • 点击应用

这应该更新你的资料库和您试图访问应该是提供给您的版本。

0

谷歌的Maven仓库添加到您的项目的摇篮文件:

allprojects { 
    repositories { 
     //... 
     maven { 
      url "https://maven.google.com" 
     } 
    } 
} 
+0

我之前添加了这个,但没有工作,这里是我的gradle我编辑它的问题。检查它 –