Error on new project: Unable to resolve dependency for ': app@debug/compileClasspath'

Asked 1 years ago, Updated 1 years ago, 74 views

I'm a fairly good programmer, but I'm a super beginner at Android programming.

I installed AndroidStudio(3) on Windows 7 and created a new project.
The build will not pass due to a sudden error.

There are several errors, but they are basically as follows:

Unable to resolve dependency for ':app@debug/compileClasspath':Could not 
resolve com.android.support:appcompat-v7:26.1.0.Open File Show Details

All settings are initial and the project is empty.
Is this what it is in the first place?

Then I modified Dependencies and the build passed.

app/build.gradle Contents

android{
    compileSdkVersion26
    defaultConfig {
        Abbreviated.
        minSdkVersion26
        targetSdkVersion26
        Abbreviated.
    }
        Abbreviated.
}

dependencies {
        Abbreviated.
    implementation'com.android.support:appcompat-v7:26.+'//←appcompat-v7:26.1.0
    // testImplementation 'junit:junit:4.12'
    androidTestImplementation'com.android.support.test:runner:0.+'//←runner:1.0.1
    androidTestImplementation'com.android.support.test.espresso: espresso-core: 2.+'//← espresso-core: 3.0.1
}

By the way
~\AppData\Local\Android\Sdk\extras\android\m2 repository\com\android\support\

Each of the following: The affected version of the library does not exist, but there was an older version.

Also
for junit:junit:4.12 C:\Program Files\Android\Android Studio\lib\junit-4.12.jar
There is, but I don't know how to browse here.

Do I have to procure these on my own (instead of Studio setting them up automatically)?

android-studio

2022-09-30 16:30

1 Answers

https://developer.android.com/studio/build/dependencies.html#google-maven
More

Allow all projects to load the Google() repository
<projectRoot>/build.gradle

allprojects{
    repositories {
        google()

        // If you're using a version of Gradle lower than 4.1, you must install use:
        // maven{
        //     url'https://maven.google.com'
        // }
        // Alternative URL is'https://dl.google.com/dl/android/maven2/'
    }
}

Or maybe you can add it to the module.

<projectRoot>/app/build.gradle

repositors{
    maven{
        url'https://maven.google.com'
    }
}


2022-09-30 16:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.