[android] weird behaviour when working with two modules

Hi All

I am working on a library which is intended for Android. What means i have to work with two modules, one is the library im working on, and the other is an application which uses this library. I did get it working once but I forget how, and suddenly yesterday night it just stopped working. Any ideas what am I doing wrong??

Thanks, Amit.


Here is what I get:
=============


Information:Compilation completed with 22 errors and 11 warnings
Information:22 errors
Information:11 warnings
Error:UNEXPECTED TOP-LEVEL EXCEPTION:
Error:java.lang.IllegalArgumentException: already added: Ljunit/framework/TestSuite;
Error:at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
Error:at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
Error:at com.android.dx.command.dexer.Main.processClass(Main.java:372)
Error:at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
Error:at com.android.dx.command.dexer.Main.access$400(Main.java:59)
Error:at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
Error:at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
Error:at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
Error:at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
Error:at com.android.dx.command.dexer.Main.processOne(Main.java:313)
Error:at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
Error:at com.android.dx.command.dexer.Main.run(Main.java:185)
Error:at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:at java.lang.reflect.Method.invoke(Method.java:597)
Error:at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:118)
Error:at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:193)
Error:at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:75)
Error:1 error; aborting
Warning:warning: Ignoring InnerClasses attribute for an anonymous inner class
Warning:(net.sf.antcontrib.logic.ForEach$1) that doesn't come with an
Warning:associated EnclosingMethod attribute. This class was probably produced by a
Warning:compiler that did not target the modern .class file format. The recommended
Warning:solution is to recompile the class from source, using an up-to-date compiler
Warning:and without specifying any "-target" type options. The consequence of ignoring
Warning:this warning is that reflective operations on this class will incorrectly
Warning:indicate that it is *not* an inner class.
Warning:(net.sf.antcontrib.net.PostTask$1) that doesn't come with an
Warning:(net.sf.antcontrib.net.PostTask$2) that doesn't come with an
Warning:(net.sf.antcontrib.process.Limit$1) that doesn't come with an

4 comments
Avatar
Eugene Kudelevsky
Comment actions Permalink

You should mark your "library" module as Android library: Project structure | Android facet settings | Is Library project checkbox

0
Comment actions Permalink

Hi Eugene,

Thank you for your useful answer. However, I have migrated to whole thing under windows (even though i am highly uncomfortable with it) but at least Idea is working much much better under windows that under linux. I looked at the preference you have mentioned and saw that it is still working even when the library is not markt as library project (as far as I know library projects are android application, and in this case it is not a complete application but merely a library). Anyway can u assume any reason why it would not work under Ubuntu 11.04, but smoothly under win7 ??

Thank you so much,

Amit.

0
Avatar
Eugene Kudelevsky
Comment actions Permalink

No, It must be a configuration issue. Do you open exactly the same project under Windows and Linux? Do you have any dependencies on JUnit library, which contains the class appearing in the exception?

0
Comment actions Permalink

I have this same basic setup working in Windows.  I use the library as the base for 5 applications.

THe module setting is what helped me get it working, but also ensure you are running your application, not your library.

And under your Application Module, ensure you have the Library marked as a Exported Module Dependency.

0

Please sign in to leave a comment.