Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine which minSDKVersion to set for my Android App

How can I determine the minimum API Level or Maximum API Level used in my project? And is there any way to determine which part of code in my project uses which API Level?

Is there anyway in android studio to determine minimum API Level & maximum API Level used in my project? Like for example "TODO" tracks of all tasks etc, do we have any feature in Android studio to determine minimum API Level & maximum API Level used in my project?

I'm newbie so please bear with me.

like image 846
Gemma Avatar asked Jul 01 '20 20:07

Gemma


People also ask

How do I choose minSdkVersion?

When deciding on a minSdkVersion, you should consider the stats on the Dashboards, which give you a global look on all devices that visited the Google Play Store in the prior 7 days — that's your potential audience when putting an app on Google Play.

What should be minSdkVersion in Android?

android:minSdkVersion — Specifies the minimum API Level on which the application is able to run. The default value is "1".

What API level should I use Android?

Starting November 1, 2022 if your app doesn't target API level 30 or above, new users with newer Android OS versions won't be able to discover or install your app on Google Play. You can request an extension if you need more time to update your app.

Why do we specify minSdkVersion attribute for the Android application?

minSdkVersion is the minimum API Level with which the app is compatible. The Android system will prevent a user from installing the app if the system's API Level is lower than the value specified in this attribute. Android requires the minSdkVersion attribute to always be set.


2 Answers

To determine minSdk and maxSdk see build.gradle(Module: app) in Gradle Scripts. See the project structure:

  • compileSdkVersion is de maxSdk.
  • minSdkVersion is minSdk.
  • targetSdkVersion is de maxSdk tested version.
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "app.id"
        minSdkVersion 21
        targetSdkVersion 29
        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 = 1.8
        targetCompatibility = 1.8
    }
}
like image 187
Norman Daniel Vicente Avatar answered Sep 29 '22 17:09

Norman Daniel Vicente


For the absolute minSdkVersion that you can actually set for the current status/version of app (as you said in comments) you can identify it using brute force:

  1. Set minSdkVersion to 1
  2. build the project.
  3. If it builds then current minSdkVersion is the absolute minSdkVersion, else it will give an error telling some dependencies to the anotherSdkVersion, now set minSdkVersion to anotherSdkVersion --go to step 2.
like image 43
Muhammed Can Küçükaslan Avatar answered Sep 29 '22 16:09

Muhammed Can Küçükaslan