On Nov 29, 2011, at 2:15 PM, Jonathan Pobst wrote:
> You simply won't have access to Android APIs added in 2.2 or 2.3.
> 
> If you aren't using them, then nothing is lost.
> 
> If you want to use them when they are available, you will have to 
> "target" 2.2, set a minimum version of 2.1 in the manifest, and then 
> ensure you do runtime checks so you only call 2.2+ APIs on 2.2+ devices.

Note that this is potentially brittle. Very brittle. The TargetFrameworkVersion 
you build against specifies the ABI which is being targeted, and a Java-side 
change can be source-compatible while breaking ABI, at least the JNI ABI that 
Mono for Android uses.

For example [0], consider android.view.MotionEvent [1]. In API levels 1 through 
8, MotionEvent inherited java.lang.Object, and methods such as getDeviceId()[2] 
were declared on MotionEvent. In API level 9, the new android.view.InputEvent 
[3] type was added, and the MotionEvent.getDeviceId() method was _moved_ to 
InputEvent.getDeviceId().

This is a source compatible change (the method is still there), and it's a 
backward compatible change (apps built against API level 8 still work on API 
level 9), but it's not a "forward compatible" change, at least not for a Mono 
for Android app: if you build your MfA app against API level 10 and use the 
MotionEvent.DeviceId property, the JNI code will be attempting to invoke the 
InputEvent.getDeviceId() method...which doesn't exist on a target < 9. Result: 
BOOM.

So can you do it? Yes. Do you need to be damn careful and test everything 
thoroughly? Yes.

 - Jon

[0] This "example" broke our test app, and is the single significant reason 
that we moved from a single Mono.Android.dll usable for all Android versions to 
a per-API level Mono.Android.dll.
[1] http://developer.android.com/reference/android/view/MotionEvent.html
[2] 
http://developer.android.com/reference/android/view/MotionEvent.html#getDeviceId()
[3] http://developer.android.com/reference/android/view/InputEvent.html
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to