Android Project with plain Java libraries

Hi everyone.

I am developing an Android application, where I want part of project to have as a library (module) in Idea.

so one module is Android UI module with Gradle support, and I want to use another module from within the same project, which contains no android code, just lot of java classes. currently I cannot compile this, as I am getting following error:
Gradle: module 'Engine' won't be compiled. Unfortunately you can't have non-Gradle Java module and Android-Gradle module in one project.

if I add the module "library" as a module depencency to the "UI" android module, it cannot find the package from the library module.

last step is to have a executable java class where I can use classes from library module and use them in the executable java class.

how should I set up such project?

thank you very much in advance


1 comment
Comment actions Permalink

Hello, Marek

Sorry about the delay. First, please make sure that you use the latest IDEA 13.0.2 EAP. Previos versions may have some problems related to your situation. Then, your module for pure java code should be Gradle module too - as you can see from the message, we don't support compilation of gradle and non-gradle modules in one project. To create such module, you may use "New Module | Gradle: Java Library". Also you have to add following dependency into the "dependencies" section of build.gradle file in your Android module: "compile project(':MyLibrary')". Then compilation should work fine, but you classes from java library won't be resolved from the Android module: you need to perform "refresh" from Gradle tool window to synchronize IntelliJ dependencies with Gradle dependencies. I know that it may be not obvious, you may submit your suggestions through our tracker.


Please sign in to leave a comment.