簡體   English   中英

我們建議使用較新的 Android Gradle 插件來使用 compileSdk = 33

[英]We recommend using a newer Android Gradle plugin to use compileSdk = 33

嘿家伙我怎么能更新到最新版本,因為我找不到最新的gradle-plugin 有人可以指導我嗎?

build.gradle(示例應用程序)

buildscript {
    ext {
        kotlin_version = '1.6.10'
        kotlin_serializtion_version = '1.5.21'
        kotlin_coroutines_version = "1.6.0"
        moshiVersion = "1.13.0"
        retrofit2_version = "2.9.0"
        okhttp3_version = "4.9.0"
        mockk_version = "1.12.2"
        picassoVersion = "2.71828"
        lifecycle_version = "2.5.0"
        koin_version = "3.2.0"
        barcode_scanner_version = "16.1.1"
        camerax_version = "1.0.0"
        camera_view_version = "1.0.0-alpha22"
        stripe_version = "19.1.0"
        jacoco_version = "0.8.7"
        room_version = "2.4.1"
        glide_version = "4.12.0"
        json_version = "20180813"
        kotlin_reflect_version = "1.6.10"
        compose_version = '1.2.0-rc03'
        espresso_version = '3.4.0'
        core_testing_version = '2.1.0'
        pdf_view_version = '3.2.0-beta.1'
        appboy_version = '21.0.0'
        mp_chart_version = "3.1.0"
        activity_compose = "1.5.0"
        compose_material3 = "1.0.0-alpha14"
    }

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_serializtion_version"
        classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.0'
    }
}

plugins {
    id "org.sonarqube" version "3.3"
}
apply from: "${rootDir}/config/sonarqube/sonarqube.gradle"

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release' }
        maven { url 'https://mobile-sdk.jumio.com' }
        maven { url "https://appboy.github.io/appboy-android-sdk/sdk" }
        maven { url 'https://jitpack.io' }
    }
}

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

gradle-wrapper.properties

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

build.gradle(:應用程序

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.google.firebase.appdistribution'

android {
    compileSdkVersion 33

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 21
        targetSdkVersion 33
        .....
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }

    sourceSets {
        test {
            java.srcDirs =
                [
                    "${project.projectDir}/src/test/java"
                ]
        }
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    buildFeatures {
        viewBinding true
        compose true
    }

    composeOptions {
        kotlinCompilerExtensionVersion = "1.2.0"
        kotlinCompilerVersion kotlin_version
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.browser:browser:1.4.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation "androidx.fragment:fragment-ktx:1.5.0"
    implementation 'com.google.android.play:core:1.10.3'
    implementation 'com.google.android.material:material:1.5.0'

    // kotlin atomic
    implementation 'org.jetbrains.kotlinx:atomicfu:0.17.1'

    //Kotlin extensions library for Play Core
    implementation 'com.google.android.play:core-ktx:1.8.1'

    //Android Kotlin extensions
    implementation "androidx.core:core-ktx:1.8.0"

    //Unit test
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-inline:3.4.0'
    androidTestImplementation 'org.mockito:mockito-android:3.4.0'
    testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
    testImplementation 'androidx.arch.core:core-testing:2.1.0'
    testImplementation "io.mockk:mockk:${mockk_version}"
    testImplementation "org.json:json:$json_version"

    //Moshi (JSON parser)
    implementation "com.squareup.moshi:moshi-kotlin:$moshiVersion"
    kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"

    //Retrofit2
    implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofit2_version"

    //Paging 3
    implementation "androidx.paging:paging-runtime-ktx:3.1.1"

    //Okhttp3
    implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
    testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp3_version"

    //Kotlin Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_version"

    //ViewModel and LiveData
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"

    //HTML parser
    implementation 'org.jsoup:jsoup:1.12.1'

    //Payments
    implementation 'com.google.android.gms:play-services-wallet:19.1.0'
    implementation "com.stripe:stripe-android:$stripe_version"

    //Firebase
    implementation platform('com.google.firebase:firebase-bom:27.1.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-config-ktx'
    implementation "com.google.firebase:firebase-messaging"
    implementation "com.google.firebase:firebase-core"

    //Pager indicator
    implementation 'me.relex:circleindicator:2.1.4'

    //Animations
    implementation 'com.airbnb.android:lottie:3.2.2'
    implementation 'pl.bclogic:pulsator4droid:1.0.3'

    //Loading images
    implementation "com.github.bumptech.glide:glide:$glide_version"
    kapt "com.github.bumptech.glide:compiler:$glide_version"

    //View container which can wrap content
    implementation 'com.google.android:flexbox:2.0.1'

    //Phone Authentication
    implementation 'com.google.android.gms:play-services-auth:20.1.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.7.0'

    //Video player
    implementation 'com.google.android.exoplayer:exoplayer:2.11.3'

    //Dependency injection - Koin AndroidX Scope features
    implementation "io.insert-koin:koin-android:$koin_version"
    implementation "io.insert-koin:koin-androidx-workmanager:$koin_version"
    testImplementation "io.insert-koin:koin-test-junit4:$koin_version"
    testImplementation "io.insert-koin:koin-test:$koin_version"

    //WorkManager
    implementation "androidx.work:work-runtime-ktx:2.7.1"

    // App Startup
    implementation "androidx.startup:startup-runtime:1.1.0"

    //Progress button extension
    implementation 'com.github.razir.progressbutton:progressbutton:2.1.0'

    //PDF Viewer
    implementation "com.github.barteksc:android-pdf-viewer:$pdf_view_version"

    //Amplitude
    implementation 'com.amplitude:android-sdk:2.25.2'

    //Salesforce chat
    implementation "com.salesforce.service:chat-ui:4.2.2"

    //Jumio
    implementation "com.jumio.android:core:3.9.2@aar"   // Jumio Core library
    implementation "com.jumio.android:nv:3.9.2@aar"     // Netverify library
    implementation "com.jumio.android:nv-barcode:3.9.2@aar"   // Barcode scanning
    implementation "com.jumio.android:nv-mrz:3.9.2@aar" // MRZ scanning

    //AppsFlyer
    implementation 'com.appsflyer:af-android-sdk:6.2.0'
    implementation 'com.android.installreferrer:installreferrer:2.2'

    // Code Scanner & Camera
    implementation "com.google.mlkit:barcode-scanning:$barcode_scanner_version"
    implementation "androidx.camera:camera-camera2:$camerax_version"
    implementation "androidx.camera:camera-lifecycle:$camerax_version"
    implementation "androidx.camera:camera-view:$camera_view_version"

    // Braze (marketing push notifications)
    implementation "com.appboy:android-sdk-ui:$appboy_version"

    // Room
    implementation "androidx.room:room-ktx:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    androidTestImplementation "androidx.room:room-testing:$room_version"
    implementation "androidx.room:room-runtime:$room_version"

    // Compose
    implementation "androidx.compose.material3:material3:$compose_material3"
    implementation "androidx.compose.runtime:runtime:$compose_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.foundation:foundation:$compose_version"
    implementation "androidx.compose.foundation:foundation-layout:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation "androidx.activity:activity-compose:$activity_compose"
    androidTestImplementation "androidx.compose.ui:ui-test:$compose_version"
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

    // MP Charts
    implementation "com.github.PhilJay:MPAndroidChart:v$mp_chart_version"

    // Testing dependencies
    androidTestImplementation "androidx.arch.core:core-testing:$core_testing_version"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$espresso_version"
    androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"

    // Modules
    lintChecks project(':lint')

    // Miscellaneous
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_reflect_version"
    //Memory leak analysis - should only run in dev builds (devqaImplementation)
    //devqaImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
}

收到此警告消息,我已經更新了我缺少的所有內容,有人能告訴我嗎?

We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.2.1) was tested up to compileSdk = 32

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33

謝謝

由於此消息只是一個警告,如果您的構建工作正常,我建議您取消警告並且暫時不要更新您的 Android Gradle 插件。 升級這個插件會給你帶來更多的麻煩。

The Android Gradle plugin is published to the Google's Maven repository at maven.google.com .

可以在此處找到該插件及其所有版本的列表。 您可以選擇該列表的一個版本並測試您的構建。

只需使用所需版本更新build.gradle文件的以下行:

dependencies {
    classpath 'com.android.tools.build:gradle:<NEW_VERSION_HERE>'
    ...
}

請記住,您可能需要將 Android Studio 更新到 Beta 或 Canary 頻道才能毫無問題地使用該插件的較新版本。

以下更改對我有用:

Ctrl+Alt+Shift+S

在 ProjectStructure 中更改

模塊/屬性/編譯 SDK 版本/33

模塊/默認配置/目標 SDK 版本/33

模塊/默認配置/最小 SDK 版本/33

比選擇帶有 API 33 的模擬器,示例:Pixel 6 API 33

build.gradle(項目)中更新插件

id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false

這個對我有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM