Reputation: 15039
I have just migrated a project from Exclipse to Android Studio.
The build.gradle
file has a section that includes:
defaultConfig {
applicationId "com.example.someone.myapplication"
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
The same thing is in the uses-sdk
element of the AndroidManifest.xml
.
When both settings are simultaneously present, which settings are respected?
Also, should I remove them from AndroidManifest.xml
? My project must support Api-8 at least. Would it make any difference on old platforms if the uses-sdk
section is removed from the manifest file?
Upvotes: 5
Views: 2695
Reputation: 118
You only need to define the min SDK and target SDK in the build.gradle
file. The Gradle build system will automatically define these values in the manifest when you build.
If you define them in both the build.gradle
and AndroidManifest.xml
files, the settings in the build.gradle
file will override the manifest ones.
Best practice is to completely remove the <uses-sdk>
tag in the manifest and only use the build.gradle
file to specify the min SDK and target SDK. This will not make any difference for older devices; it will run exactly the same.
defaultConfig {
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
The same thing applies for the versionCode
and versionName
settings.
Upvotes: 10