I would like to build two different versions of my app using different android:minSdkVersion. In the lower sdk version I would simply omit the function that needs the higher sdk. (Disable the user interface item that needs the higher version)
I understand that I can “Publishing Multiple APKs with Different Filters” (for different sdk versions) (http://developer.android.com/guide/google/play/filters.html#MultiApks). In my code and AndroidManifest.xml file I would need something like “#ifdef”, but this doesn’t seem to work in xml files.
What would be the best approach to minimize (error-prone) manual changes for each rebuild?
Or is there a way to specify the lower sdk version in the manifest and nevertheless use the methods of the higher version when available, i.e. dynamically enable the call to the method depending on the current android version?
Yes, you can create one APK with conditional blocks that execute different statements depending on the API version of the device. For example, you can check the value of
android.os.Build.VERSION.SDK_INTand take appropriate actions.