1
votes

I upgraded my AS and errors start to appear
I looked every where and i couldn't solve the problem

apply plugin: 'com.android.application'

android {
    buildToolsVersion "26.0.2"
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.student.myapplication"
        minSdkVersion 23
        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'
}

the error message

this is my build.gradle(project), offline is unchecked, i did the invalidate and restart nothing worked,

// 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:3.0.1'

            // 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
    }

what it means couldn't resolve the dependence ? this is what i got when i added the repositories to gradle(app)

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 Could not resolve com.android.support:appcompat-v7-26.1.0:. Could not get resource 'https://repo1.maven.org/maven2/com/android/support/appcompat-v7-26.1.0//appcompat-v7-26.1.0-.pom'. Could not GET 'https://repo1.maven.org/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://maven.google.com/com/android/support/appcompat-v7-26.1.0//appcompat-v7-26.1.0-.pom'.

i looked at the gradle console and i found links of where the problem at, i clicked them and they opened in the browser with an error 404 gradle console

2
Please add your other gradle file that defines the repostioriesOneCricketeer
just edited and uploaded the project build.gradleAyman Subbagh

2 Answers

0
votes

you can try adding these to your dependencies..

   repositories {
    mavenCentral()
    maven { url 'https://maven.google.com' }
}

this is what it should look like.

apply plugin: 'com.android.application'

repositories {
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }

    android {
        buildToolsVersion "26.0.2"
        compileSdkVersion 26
        defaultConfig {
            applicationId "com.student.myapplication"
            minSdkVersion 23
            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'
    }
0
votes
  1. Make sure your machine is connected to the internet.
  2. Go to project level build.gradle file, it should look like this:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
    
        repositories {
            google()
            jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    
    
        // 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
    }
    
  3. Go to File -> Settings & expand Build, Execution, Deployment -> Gradle -> UNCHECK Offline work -> OK

  4. Go to File -> click on Invalidate Caches / Restart -> Invalidate & Restart