Scala library for Android

I read the IntelliJ Idea 12+ Android + Scala topic at the moment , which seemed to be pretty much what I needed. However, I need something a little different: I just want to create a library in Scala and use it in an Android project. This Android project can also use Java or Scala, it does not matter. I do not want to create an entire android project in Scala.

So how do I create such a library?

Do I need to create an android project using the tutorials here http://fxthomas.imtqy.com/android-plugin/ ? Or the usual Scala library , which does not know about android at all (the fact that it will be used in the Android project), and then when I add it to the android project, will I need to add Scala support?

PS I am using IntelliJ Idea 12 and sbt.

+2
java android scala intellij-idea sbt
30 Oct '13 at 16:18
source share
1 answer

To find out if you need an Android project (library-) or a regular Scala application, you need to clearly indicate your use case. In fact, you should ask yourself the same question when you build a Java-based Android library.

When your library provides any resources (graphics, xml-views, ...), you need to create a library project, because when you complete the project in a *.jar file, these resources will not be available anymore. When you create a library project, you also provide the source code of the library to your users.

If this is not the case, and everything you want to build falls into the *.class files, you can continue the general Scala project. The resulting *.jar file can then be used as a library. And even in such a Scala project, you can refer to the Android API if you add android.jar depending on the project.

 libraryDependencies += "com.google.android" % "android" % "4.1.1.4" % "provided" 
+1
Feb 10 '14 at 17:37
source share



All Articles