首页 > 解决方案 > 导入android支持库

问题描述

我对android完全陌生,我正在尝试一些东西。但是有一个我无法解决的问题。我正在尝试导入一些 android 支持库,即使通过将 google() 添加到我的 Gradle 构建并单击 Sync Now 似乎我做得正确,但出现错误。我什至使用项目结构管理器添加依赖项,它仍然显示为红色。这是我的 build.gradle 模块文件:

plugins {
    id 'com.android.application'
}

allprojects {
    repositories {
        google()
    }
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.avoidspleen.exossupspe"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    // Appears red from now
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    // End of red
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

我正在使用 JetBrains 工具箱来更新 Android Studio 版本 4.1.2。

标签: androidandroid-studiobuild.gradle

解决方案


推荐阅读