首页 > 解决方案 > 尝试在 Android Studio 3.5.3 中创建新项目时出现很多错误

问题描述

我想使用 Kotlin 在 Android Studio 3.5.3 中创建一个项目,但是我遇到了很多错误。

第一个错误是:

Could not find androidx.appcompat:appcompat:1.1.0.
Required by:
    project :app

经过大量搜索后,我将 maven 添加到存储库:

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

    }
}

现在我收到这些错误:

ERROR: Failed to resolve: androidx.core:core-ktx:1.2.0
Show in Project Structure dialog
Affected Modules: app


ERROR: Failed to resolve: constraintlayout-solver
Affected Modules: app


ERROR: Failed to resolve: androidx.test.espresso:espresso-core:3.2.0
Show in Project Structure dialog
Affected Modules: app

我不知道我应该怎么做才能消除这些错误。我尝试了很多方法,但我无法解决这些错误。

这是我的build.gradle文件:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 17
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

标签: android-studiokotlin

解决方案


推荐阅读