如何在 Android Studio 中“SDK 30 和 Android 10”?

How do I " SDK 30 and Android 10" in Android Studio?

当我更新项目时,此消息出现在 Android Studio 中, 我想在“SDK 30 and Android 10”环境中构建项目, 但是我不知道怎么做。

gradle 包装属性

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

构建gradle项目

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

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

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

构建gradle应用程序

apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.0"
    defaultConfig {
        applicationId "com.demo.codev2"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true
        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 fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'com.android.support:support-annotations:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation 'com.victor:lib:1.0.4'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'me.iwf.photopicker:PhotoPicker:0.9.12@aar'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'com.wang.avi:library:2.1.3'
    implementation 'com.github.chrisbanes:PhotoView:2.0.0'
    implementation 'com.github.krokyze:ucropnedit:2.2.1-native'
    implementation 'com.github.duanhong169:colorpicker:1.1.6'



}

当我更新项目时,此消息出现在 Android Studio 中, 我想在“SDK 30 and Android 10”环境中构建项目, 但是我不知道怎么做。

谢谢

enter image description here

转到SDK Manager > SDK Tools

检查Show Package Detail 并安装 SDK Tools 30

see on here

mavenCentral()(阅读更多内容 )从您的 build.gradle 中丢失。

您的 gradle.build 文件应如下所示:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        mavenCentral()
    }
    
    dependencies { classpath 'com.android.tools.build:gradle:3.4.3'  }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        mavenCentral()
    }
}

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

project seems to be deprecated (they recommend this 其他)一样,如果这不起作用,您需要下载库并将其手动添加到项目 lib 文件夹中。