I just discovered something weird about Android studio: it has some configuration options in the build.gradle
file that override what is specified in the AndroidManifest.xml
file.
For instance, I had the following lines in build.gradle
:
android { compileSdkVersion 18 buildToolsVersion "18.1.1" defaultConfig { minSdkVersion 10 targetSdkVersion 10 } ... }
which was overriding the corresponding tag in AndroidManifest.xml
:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>
I don't really like to have the same settings spread in two different files, so I am wondering if I can safely remove it either from build.gradle
or AndroidManifest.xml
and where it makes more sense to keep it.
minSdkVersion : The min sdk version is the minimum version of the Android operating system required to run your application. targetSdkVersion : The target sdk version is the version your app is targeted to run on. Follow this answer to receive notifications.
Relationship between compile and target SDK versionsEven if the compileSdkVersion and targetSdkVersion have completely different meanings they are obviously not independent.
Step 1: Open your project in Android mode then go to Gradle Scripts > build. gradle(Module: app) as shown in the following image. Step 2: Refer to the below image and here you have to change the minSdkVersion and targetSdkVersion as per the requirement.
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. Show activity on this post. Set the min SDK version in your project's AndroidManifest.
Gradle overrides the manifest values, and I prefer to update the build.gradle
file rather than the manifest. Probably this is the right way using Gradle. Gradle supports product flavours which can be controlled via an IDE and those product flavors can change many things in our Manifest like package name, version code, version name, target SDK and many other. Then by one click in Android Studio you can change many properties and generate another apk.
You can leave the manifest as it is and do all configuration in build.gradle
. You can safely remove
<uses-sdk></uses-sdk>
from manifest as well as version codes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With