Android. Dynamic class loading and Java interfaces
<p>I've almost finished my first real Android project, a taxi ordering application, only some little usability concerns are left. For future releases we plan to implement built-in automatic updates of programming code and resources like some good programs do. I managed to run a simple example, based on <a href="http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html" rel="nofollow">http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html</a>, <a href="http://stackoverflow.com/questions/3022454/how-to-load-a-java-class-dynamically-on-android-dalvik">How to load a Java class dynamically on android/dalvik?</a> and <a href="http://stackoverflow.com/questions/6857807/is-it-possible-to-dynamically-load-a-library-at-runtime-from-an-android-applicat?rq=1">Is it possible to dynamically load a library at runtime from an Android application?</a>. I will not post here complete code, it looks much like over the links above. Main apk acts as launcher, it loads a jar-file from SD-card, loads a special class from there, instantiates an obect and calls its method via Java Reflect API, that simply brings up ab AlertDialog.</p>

<p>But I want to be able to use common base Java interfaces both in launcher and in loaded library, acting as API. So I tried to declare an inteface called Problem both in launcher and library. The code is like this:</p>

<pre><code>Class&lt;?&gt; problemClass = cl.loadClass("ru.homez.euler.Problem1");
Problem problem = (Problem)problemClass.newInstance();
problem.solve(this);
</code></pre>

<p>Dalvik VM doesn't like this, i get </p>

<blockquote>
  <p>java.lang.IllegalAccessError: Class ref in pre-verified class resolved
  to unexpected implementation</p>
</blockquote>

<p>I think this happens due to that Problem interface is defined both in launcher and library, I have seen issues like that here. How to deal with this?</p>
