user7352334
user7352334

Reputation:

Where is android sdk version defined?

Android documentation defines

<uses-sdk android:minSdkVersion="integer"
      android:targetSdkVersion="integer"
      android:maxSdkVersion="integer" />

In AndroidManifest.xml, but a new project created by Android Studio does not contain it. Where are the sdk versions defined?

Upvotes: 0

Views: 453

Answers (2)

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29794

If you declare it like this:

<uses-sdk android:targetSdkVersion="25" 
          android:minSdkVersion="15" />

it will be ignored when you build it with Gradle, but other build systems might certainly rely on it being there.

In your app build.gradle, you can define it as the following:

android {

  compileSdkVersion 25
  buildToolsVersion '25.0.2'

  defaultConfig {
    minSdkVersion 15
    targetSdkVersion 25

    applicationId 'com.example.app'
    versionCode 1
    versionName "1.0"
  }

  ...
}

And please be noted that you need to match the API Level in those:

  • compileSdkVersion
  • buildToolsVersion
  • targetSdkVersion

And if you add Support Library to your dependencies, you also need to match it to your API Level. For example, if you use API Level 25 as the targetSdkVersion, you need to add the following when using appCompat-V7:

dependencies {
    compile "com.android.support:appcompat-v7:25.2.0"
}

Upvotes: 1

sandesh bafna
sandesh bafna

Reputation: 31

all your gradle and sdk detetails you will get in build.gradle (mosule:app) file of gradle script you can even change them here but you need to rebuild your project again after changing anything in herethe following link will show you image of this file

Upvotes: 0

Related Questions