Search code examples
androidcordovaphonegap-buildcordova-3

What is the purpose of android:minSdkVersion and android:targetSdkVersion in the AndroidManifest.xml with respect to phoneGap/Cordova?


There is a line in the AndroidManifest.xml

android:minSdkVersion="10" android:targetSdkVersion="19"

Does it mean that if I include minimum and maximum SDK version in the AndroidManifest.xml file and build the APK using phonegap/cordova CLI (Command Line Inteface),
than a SINGLE APK file generated can be installed on ALL Android Devices ranging from Android 2.3.4 to Android 4.4

I have read posts that developing using Android SDK(native APP) it enables the APP to work on the range of devices.

Is it true for PhoneGap/Cordova generated APK file as well? (Note: I am not planning to use Google Play services for distributing the APP.)
Do we need to generate APK file for each SDK version?


Solution

  • The implications of these two variables is the same for both native apps and PhoneGap/Cordova apps.

    minSdkVersion will set the minimum version of Android required to run your application. If a user is running any version below this, they will not be able to install your application (regardless of whether or not you are distributing via the Play Store).

    targetSdkVersion specifies the latest version of Android that you have tested for. It will not change who can install your app, but it will change the behavior of your application. For example, if this is less than 14, you won't have an action bar. If it is less than 19, then users running KitKat and above will not see your content in a Chrome-backed WebView (it will be the older WebView implementation).

    Generally you just set targetSdkVersion to the latest available version of Android.

    Do we need to generate APK file for each SDK version?

    No. You need one APK with mindSdkVersion set to the minimum version you support and targetSdkVersion to the latest version of Android you have tested against.

    You can specify a maxSdkVersion, which will actually limit the maximum version you support, but you generally should not do this unless you have a good reason to.