Android Studio构建失败。

3

我来找你是因为在Android Studio编译我的安卓项目时出现了构建错误(即使是更基本的项目):每次需要下载依赖项或其他内容时,我都会遇到相同的问题。

Error:A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugUnitTestApkCopy'.

无法解决junit:junit:4.12。 要求: Android_VisiteARLabs:app:未指定 无法解析junit:junit:4.12。 无法获取资源'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'。 无法GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'。 sun.security.validator.ValidatorException: PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到所请求的目标的有效认证路径。
我不知道它来自哪里,我在代理后面工作,但我已经正确配置了它:在Android Studio中进行测试连接运行良好,并且使用浏览器,我可以轻松访问所需依赖项的路径...
我尝试过没有代理,但也没有成功。
我找不出它来自哪里。

编辑:

这是我的应用程序 "build.gradle":

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.user.app"
    minSdkVersion 15
    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.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    testCompile 'junit:junit:4.12'
}

这是我的项目 build.gradle 文件:

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.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
}

2个回答

4

将网络根SSL证书安装到jre cacerts中并不是解决方案,除非不是唯一的解决方案。

我在build.gradle文件中精确指定了jcenter bintray存储库的URL。之前是这样的:

jcenter()

现在的情况是这样的:
jcenter{url "http://jcenter.bintray.com/"}

感谢您的帮助,

2

您需要将网络根SSL证书安装到JRE cacerts中!已经有很多次回答了,参考答案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接