How to change the minSdkVersion of a project?

Android

Android Problem Overview


I have been building a project and testing it on the Android emulator.

I realized that I set the minSdkVersion to 10. Now, I have a phone to test the program on, but its sdk version is 7.

I tried to go into the manifest file, and change the sdk version to 7, but every time I run the program, it crashes.

How can I rebuild or change the sdk version to a lower number (from 10 to 7), so that I can make sure my app is able to run on older phones?

Android Solutions


Solution 1 - Android

In your app/build.gradle file, you can set the minSdkVersion inside defaultConfig.

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.name.app"
        minSdkVersion 19    // This over here
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

Solution 2 - Android

Set the min SDK version within your project's AndroidManifest.xml file:

<uses-sdk android:minSdkVersion="4"/>

What exactly causes the crash? Iron out all crashes/bugs in minimum version and then test in higher versions.

Solution 3 - Android

This is what worked for me:

In the build.gradle file, setting the minSdkVersion under defaultConfig:

enter image description here

Good Luck...

Solution 4 - Android

Create a new AVD with the AVD Manager and set the Target to API Level 7. Try running your application with that AVD. Additionally, make sure that your min sdk in your Manifest file is at least set to 7.

Solution 5 - Android

check it: Android Studio->file->project structure->app->flavors->min sdk version and if you want to run your application on your mobile you have to set min sdk version less than your device sdk(API) you can install any API levels.

Solution 6 - Android

Set the min SDK version in your project's AndroidManifest.xml file and in the toolbar search for "Sync Projects with Gradle Files" icon. It works for me.

Also look for your project's build.gradle file and update the min sdk version.

Solution 7 - Android

Open the app/build.gradle file and check the property field compileSdkVersion in the android section. Change it to what you prefer.

If you have imported external libraries into your application (Ex: facebook), then make sure to check facebook/build.gradle also.

Solution 8 - Android

Delete this line:

<uses-sdk android:targetSdkVersion="..." />

in the file:

AndroidManifest.xml

Solution 9 - Android

If you use a cordova to build your app, for me the best soluction is change the argument cdvMinSdkVersion=15 to cdvMinSdkVersion=19 in the file platforms\android\gradle.properties

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPeterView Question on Stackoverflow
Solution 1 - AndroidjuilView Answer on Stackoverflow
Solution 2 - AndroidKonView Answer on Stackoverflow
Solution 3 - AndroidAakashView Answer on Stackoverflow
Solution 4 - AndroidWindsurferOakView Answer on Stackoverflow
Solution 5 - AndroidA.JView Answer on Stackoverflow
Solution 6 - AndroidChristian CampodónicoView Answer on Stackoverflow
Solution 7 - AndroidDharani ManneView Answer on Stackoverflow
Solution 8 - Androiduser_MGUView Answer on Stackoverflow
Solution 9 - AndroidAlexandre MuzulãoView Answer on Stackoverflow