2017-06-20 23 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我編輯它的問題。檢查它 –