android - 新安装的 android studio 不会构建新的应用程序

标签 android android-gradle-plugin

我似乎无法弄清楚发生了什么。

我刚刚在我的新笔记本电脑上安装了 android studio 3, 我做了所有的下载,我下载了 JDK 8。

一切似乎都很好。然后我创建了一个全新的应用程序并开始了构建过程,但是它因所有依赖项而失败,我已经下载了所有正确的 SDK 平台以及下载的 SDK 工具,

但这是来自 gradle sync 的消息:

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0. 


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test.espresso:espresso-core:3.0.1. 


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support.test:runner:1.0.1.

这是我的Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.test.testapp"
        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 {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

这是我的项目Build.gradle:

buildscript {

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


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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

我不确定这个问题,因为我有一台运行完全相同版本的 android studio 的 PC,它可以正常工作。

有什么我可能遗漏的吗?

如果我需要显示更多设置,请告诉我,但这只是全新安装

编辑:我刚刚运行了干净的项目,现在却收到了这条消息:

Error:Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not resolve com.android.support:appcompat-v7:26.1.0.
  Required by:
      project :app
   > Could not resolve com.android.support:appcompat-v7:26.1.0.
      > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
         > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
            > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve com.android.support:appcompat-v7:26.1.0.
      > Could not get resource 'https://jcenter.bintray.com/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
         > Could not GET 'https://jcenter.bintray.com/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
            > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

最佳答案

在我看来,由于这个错误,Android Studio 无法从存储库中获取依赖项:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

您是否有有效的直接互联网连接?没有代理?您可以访问 this test site 等 SSL 站点吗?用你的浏览器?

关于android - 新安装的 android studio 不会构建新的应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47229133/

相关文章:

android - 错误 :Cannot change dependencies of configuration ':app:_debugAnnotationProcessor' after it has been resolved

android - 图书馆能否避免暴露其对 Timber 的使用?

android - "Unfortunately, app name has stopped."安卓设备或模拟器

java - 单击时按钮旋转

java - 在android中将CharSequence的首字母更改为大写

android - 在 Android 中动态添加的 TextView 上单击事件

android - 错误 :org. gradle.wrapper.WrapperExecutor.forProjectDirectory(Ljava/io/File;Ljava/lang/Appendable;)Lorg/gradle/wrapper/WrapperExecutor;

java - mac 上的安卓工作室 : remove proxy settings

android - gradle 任务如何处理扩展对象

Android使用 ImageView 点击上的翻译动画从下到上和从上到下为我的相对布局设置动画