Skip to main content

Phonegap Build Apps For Specific Version and Specific Platform

Share on FacebookTweet about this on TwitterShare on Google+Share on RedditShare on StumbleUponDigg thisFlattr the authorPin on PinterestShare on TumblrShare on LinkedInPrint this pageBuffer this page

Here we will see how you can build your apps using the PhoneGap build for a specific operating system and specific version of the operating system. This post is a part of my Free Phonegap Build beginner course and we will be using the config.xml that we created in one of the tutorials in the course.

By now I assume that you are familiar with the PhoneGap build dashboard and have tried to build apps using it. A thing you might have noticed that whenever you build an app using PhoneGap build it builds for all supported platforms i.e, Android, iOS and windows. This is the default behavior,  so how can you make the build process only build for any one platform?

This can be easily achieved by adding<platform> tag as follows

This will build you app for the platforms that you specify. Note that you can add more that one <platform> tags.

 

Setting Specific Version For PhoneGap apps

Now that we know how we build for specific platforms it’s time we see how we can build for a specific version for that platform. To do that we will need a <preference> tag. A thing to note is that the value of the preference tag depends on the platform that you wish to target. let’s see a few examples

For Android

  • First we can set the minSdkVersion
This will build an app that will be supported by an Android device which has to have Android API-19 KitKat (4.4) installed at the least. This means that devices running latter version of the Android will also be able to run the app. It is a good practice to have a minSdkVersion set.

Here is what minSdkVersion means according to google docs

An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system’s API Level is lower than the value specified in this attribute. You should always declare this attribute.

 

  • Similarly we can set maxSdkVersion as follows
Contrary to minSdkVersion this sets the maxSdkVersion and it will work as you would expect. This preference is optional. Here is a quote for google docs about maxSdkVersion

To illustrate how this attribute can affect your application after system updates, consider the following example:

An application declaring maxSdkVersion="5" in its manifest is published on Google Play. A user whose device is running Android 1.6 (API Level 4) downloads and installs the app. After a few weeks, the user receives an over-the-air system update to Android 2.0 (API Level 5). After the update is installed, the system checks the application’s maxSdkVersion and successfully re-validates it. The application functions as normal. However, some time later, the device receives another system update, this time to Android 2.0.1 (API Level 6). After the update, the system can no longer re-validate the application because the system’s own API Level (6) is now higher than the maximum supported by the application (5). The system prevents the application from being visible to the user, in effect removing it from the device.

 

  • Lastly for Android we can also set targetSdkVersion as follows
The targetSdkVersion  should be the version against which you have tested your app. The google docs have the following info about targetSdkVersion

This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app’s forward-compatibility with the target version. The application is still able to run on older versions

Note:

You can add all the three preference tags for one app, the order of the tags does not matter. Just make sure you are putting the right value of the API in the preference tag.

 

For iOS

For iOS we only need to set one preference value i.e,deployment-target. It can be set as follows

 

For Windows

Phonegap build currently supports the following windows venison Windows 8.1, Windows phone 8.1, & Windows 10 (using Windows Universal App Platform). As windows has now become an operating system that runs on mobile as well as desktop you can add preference for windows can be set as follows

 

Example

Let’s see a complete example of a config.xml file that builds only for Android and targets Android KitKat and supports a minimum version of Android JellyBean.

Notice here that I am not setting maxSdkVersion by doing so the app can be also installed on any newer Android versions as we have not set any upper limit.

Note:

If you do not specify any <preference> tag to target a version of any operating system then the latest version supported by PhoneGap Build service will be used.

 

Conclusion

Targeting a specific platform during the PhoneGap build build-process will save you some wait time. Targeting a specific version will allow you to fine tune you app build even more in targeting an older version of the operating system or abandoning support for an older version and build for a new one.

Watch Video Tutorial Here:

Full Course Curriculum : Click here

 

Leave Me Your Questions And Feedback

Getting your feedback inspires me the most so hit me up in the comments here or on the comments section on my YouTube Channel or on twitter @pointDeveloper

Consider Subscribing / Donating
Subscribe To Mailing List
Donate
If my site was helpful to you, then please consider donating via paypal:

Prantik Vaghela (pointdeveloper)

Hi my name is Prantik Vaghela. I have done my Bachelors and Masters in Computer Science and am a web developer and now a Tutor through my blog. :-)

%d bloggers like this: