-1

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'
}

D.Montoya
  • 1
  • 1
  • 2
    "I'm having errors with the dependencies versions" - what error are you getting? Please include that in your question. As per [this blog post](https://medium.com/androiddevelopers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd), only your compile SDK matters for libraries. – ianhanniballake Sep 06 '22 at 05:23

1 Answers1

1

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.

Richard Onslow Roper
  • 5,477
  • 2
  • 11
  • 42
  • I am having Install_failed_old_sdk error while using targetSdk API 33 but min Sdk 21. It won't install on Andrioid Pie (API level 28). Any solution? – Kaleab Woldemariam Jun 03 '23 at 22:20
  • Are you sure the device is running API 28 because that error only occurs when u try to run an app with a minSDK version greater than the SDK installed on the target device. Confirm both of these values again, I'd say. Does not seem likely. – Richard Onslow Roper Jun 09 '23 at 15:59