Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to include a Java project in an Android project?
    primarykey
    data
    text
    <p>I am using Eclipse to develop an Android board game. I have developed the UI in an Android project.</p> <p>On the other hand, I have developed the AI in a regular Java project, because I wanted to be able to test it without all the constraints of the Android emulator (I didn't find any other way to run the code using my Windows JVM).</p> <p>Now comes the times when I want to 'join' both projects (which work fine independently), that is to use the AI Java classes from the UI.</p> <p>This is what I have tried:</p> <p>In my Android project <em>Properties</em> > <em>Projects References</em>, I ticked the Java project. This allows me to build without error the Android project (which instantiates an AI object).</p> <p>But it fails at runtime with this error:</p> <pre><code>Could not find class 'my.package.AI', referenced from method my.otherpackage.UI.onStart </code></pre> <p><strong>What would be the correct way to include the AI Java Project into my Android Project ?</strong> </p> <p>(NB: I still want to be able to develop and test the AI as a regular Java app, so I think using a <em>jar</em> or copying all the sources to the Android Project would not suit my needs)</p> <p><strong>EDIT:</strong></p> <p>I was hoping that the new ADT v17 would solve the problem, but it didn't. I have tried virtually every option available to include a project in my Android project:</p> <ul> <li>Adding or linking a source folder</li> <li>Adding a Project <em>(Java Build Path > Projects tab)</em></li> <li>Adding a Class Folder or a Library <em>(Java Build Path > Library tab)</em></li> <li>Ticking all the previously imported projets/libraries as Exported</li> </ul> <p>The only way that allows compiling and running without error is adding the JAR of the Java Project to the Android project build path.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload