2017-08-02 252 views
0

我使用android studio创建一个空白项目,但无法编译。下面 是它的错误:Android Studio无法解析依赖关系

Error:A problem occurred configuring project ':app'. 
> Could not resolve all dependencies for configuration':app:_debugUnitTestApkCopy'. 
> Could not resolve junit:junit:4.12. 
Required by: 
    project :app 
    > Could not resolve junit:junit:4.12. 
    > Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'. 
     > Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'. 
      > jcenter.bintray.com:443 failed to respond 

我试图使用代理 与失败的URL“​​” 检查代理设置,它让我成功

但是当我编译项目,它仍然是同样的错误。

这是我grandle.properties文件:

systemProp.http.proxyHost=127.0.0.1 
systemProp.http.proxyPort=1080 
systemProp.https.proxyHost=127.0.0.1 
systemProp.https.proxyPort=1080 

这是项目build.grandle文件:

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

这是应用build.grandle文件:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 26 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.example.myapplication" 
     minSdkVersion 15 
     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.android.support.constraint:constraint-layout:1.0.0-alpha7' 
    testCompile 'junit:junit:4.12' 
} 
+0

你真的想使用jUnit进行测试吗?如果没有,您可以删除该依赖项。 – Prasheel

+0

不,但只是想让它工作,确保我可以在jcenter –

+0

中使用其他库,只需检查是否已禁用脱机模式。 – Prasheel

回答

0

最后,我解决了我的问题

我使用代理是sockts5代理

的自动生成grandle.propertyies文件使用HTTP代理

后,我改变它的工作

这是我的新grandle.propertyies的grandle.properties:

org.gradle.jvmargs=-Xmx1536m -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=1080 
相关问题