简体   繁体   中英

How to downgrade Api Level (32 -> 28) Android?

I've benn programming my school proyect for several months and now im done. I used to compile my app directly to my phone (Android 12) but I need it to be at least API 28. I tried to change the Build Gradle target version from 31 to 28 but I'm having errors with the dependencies versions. There is any safe and quick way to know which version exactly I need for each dependency? Im currently using theese.

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    //Hilt
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.kdapp.estudiapp"
        minSdk 24
        targetSdk 31
        versionCode 1
        versionName "1.1"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}
apply plugin: 'com.google.gms.google-services'
dependencies {


    implementation 'androidx.core:core-ktx:1.7.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.1'
    implementation 'com.google.firebase:firebase-auth-ktx:21.0.6'
    implementation 'com.google.firebase:firebase-firestore-ktx:24.2.1'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

    //Firebase
    implementation platform('com.google.firebase:firebase-bom:30.2.0')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-auth:21.0.6'
    implementation 'com.google.android.gms:play-services-auth:20.2.0'
    //Firebase -> Storage
    implementation 'com.google.firebase:firebase-storage'


    //Navigation
    implementation 'androidx.navigation:navigation-compose:2.5.0'

    // Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.5"
    // Hilt DI
    def hilt_lifecycle_viewmodel = "1.0.0-alpha03"
    def hilt_navigation = "1.0.0-alpha03"

    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_lifecycle_viewmodel"
    implementation "androidx.hilt:hilt-navigation-compose:$hilt_navigation"
    //GSON
    implementation 'com.google.code.gson:gsoenter code heren:2.9.0'
}

Any external dependencies require version checks specified on their official GitHub repo, or their website, if it isn't open-source. Now, as of a quick way to downgrade minSdk , just press Ctrl + Alt + Shift + S within Android Studio, and it'll open the project structure dialog. Find a field that says minSdk , and set it to whatever you require. I recommend setting the targetSdk and compileSdk to the maximum value available, they won't affect your app's deployment on lower api devices. There's also a suggestions pane in the dialog, which can help you update dependency versions studio deems to be out-dated. After having set everything, click Apply/Ok.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM