0

My current project is created for API Level 4 and I use custom implementation of the interface Window.Callback there. When I'm running the project on higher API Levels I'm getting the error: java.lang.AbstractMethodError: abstract method not implemented. That's because two extra methods added to this interface since API Level 5. So any android interface can be modified in future API Levels and any application that uses modified interface will crash!? How to solve this problem? I have two solutions, which is better?:

  1. Use Proxy (this is not a problem but I don't want to complicate my code)
  2. Built project under the latest API Level and indicate min-sdk=4 (but if new API Level is created I will have to rebuild my project again?!)
Flavio
  • 6,205
  • 4
  • 30
  • 28

1 Answers1

0

Try detecting the OS version and abstracting the classes you use through interfaces. Another question covered this here: Load class based on SDK version

This should allow you to selectively load the proper implementation based on which version of the OS the device currently running your app has loaded.

Community
  • 1
  • 1
Brad Gardner
  • 1,627
  • 14
  • 14
  • I have an identical problem, also regarding Window.Callback, and I do not see how this answer solves it. The Window.Callback interface is being called directly by classes from the OS. I do not have the ability to control what version of those classes is active. Of course, I could solve the immediate problem by adding the new methods to my implementation, but that will only last until Google decides to add some more in the future. – mhsmith Aug 29 '12 at 14:18