Hi all, I'm writing code that will use slf4j on both j2se on windows/unix/mac/etc and on Android devices. The discovery of the Android sub-project was of course a very welcome one!
There is a problem though. The project has three modules. The common module needs to import the slf4j API in order to compile. The j2se module then imports the log4j jar whereas the Android module imports the Android adaption. The problem is that the Android adaption also includes the API parts already included by the common package; the Android dex compiler does not allow the same class to be added twice, so just changing the precedence of the jar files does not work. At first I mailed Thorsten Möller directly. His reply was quick (danke schön!) but as he pointed out I should of course have employed this mailing list. Here's the main body of Thorsten's reply: [[ I would approach this in a different way, using IDEA in combination with an external build system such as Maven or Ant/Ivy. Using Maven (which is my favourite build tool these days), I would proceed as follows. Create a standard POM (packaging type jar) for your project and specify logging related dependencies using two profiles (any other dependency can be placed outside profiles in the standard way as long as they are also not platform dependent). The first profile contains dependencies to the standard slf4j API, log4j, and log4j-over-slf4j. This profile is used for J2SE. The other profile contains dependencies to the android jar (groupId com.google.android, artifactId android) and the special slf4j-android jar (groupId org.slf4j, artifactId slf4j-android); all artifacts are in Maven central repository, meanwhile. Afterwards you can build your project for both platforms by activating the corresponding profile at build time. Which means that you build your project twice. However, in case of building for android you get a JAR at first. You would need to do an additional step using the Dexer to convert it into Dalvik executable. Probably you can use the maven-anroid plugin to also automate this by also placing it in the android profile. For development in IDEA, use the standard J2SE dependencies since a J2SE VM runs anyway. ]] Maven's profile feature does sound nice; I'll definitely have a look at that. If you guys have any other ideas, shout out. =) Thanks again and BR, Per _______________________________________________ slf4j-user mailing list [email protected] http://qos.ch/mailman/listinfo/slf4j-user
