Skip to content Skip to sidebar Skip to footer

How Do I Set The Minimum Api Level For Projects In Android Studio?

I recently migrated a project into Android Studio 0.4.3. When compiling, it gave me errors on several lines of java, including the following: FragmentManager fm = getFragmentManage

Solution 1:

I have 0.8.6 version and it's can be done like this:

In the menu: File -> Project Structure.

In the open menu, navigate to app, then in the tabs choose Flavors.

enter image description here


Solution 2:

If you have generated your project on recent versions of Android Studio, the setting is in gradle config file. Find build.gradle file in your application module. There should be something like this.

defaultConfig {
    minSdkVersion 7
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}

Solution 3:

Starting from gradle build system all your setting related to sdk and compilation APIs will be overridden by what you define in your build.gradle file.

So going forward if you want you can remove these all configurations from your AndroidManifest.xml and keep them in build.gradle files only to avoid confusions.

So check minSdkVersion in module's build.gradle file which is throwing the error.

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.1'

    defaultConfig {
        minSdkVersion 7      // Change 7 to 11 will solve your problem
        targetSdkVersion 19
    }

}

I prefer to have these all configurations in my top project level build.gradle file because if the configurations are different in different modules you will be ended up with Manifest Merging error.


Solution 4:

In the latest version as of dated 2020, perform the following steps:

  1. Click on Files (top left)
  2. Go to Project Structure (Ctlr + Alt + Shift + S)
  3. Click on modules
  4. In the right pane, click on Default Config (Middle one)
  5. Change Minimum SDK version
  6. Apply and click OK

Done!


Solution 5:

Full app/build.gradle minSdkVersion, targetSdkVersion

apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.yourapp.package"
    minSdkVersion 18
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

packagingOptions {
    exclude 'LICENSE.txt'
}
}

dependencies {
androidTestCompile fileTree(dir: 'libs', include: '*.jar')
androidTestCompile('com.squareup.assertj:assertj-android:1.0.0'){
    exclude group: 'com.android.support', module:'support-annotations'
    }
}

Post a Comment for "How Do I Set The Minimum Api Level For Projects In Android Studio?"