3
votes

I have been trying to create an android project within sbt for like 2 days now and I am getting a lot of run around. From the start I have been following this tutorial for just creating the sbt+android+intellij IDE project. which then directed me towards the android-sdk-plugin. I had to download sdks and set Paths before I finally was able to execute the sbt gen-android command to create a android project in the command line. However when the android sbt project is created, the following cmd line command android update project -p . does not execute because the manifest is not located at the root folder.

I troubleshooted by looking at the type safe scaloid template examples. So, my fix is to transfer both the manifest and res file to the root dir of the sbt project and move the android package to the root of the src folder to make the android update work. I have gotten things to the point where my sbt project will compile in terminal but not within intellij after importing the same project.

Before starting this process, trying to create an sbt android project with just the IDE I was getting ANDROID_HOME not set errors during compilation. Now after everything is set as far as PATHS and sdks, I get the following error when sbt compile..

[info] Processing resources [trace] Stack trace suppressed: run 'last compile:compile' for the full output. [error] (compile:compile) java.lang.IllegalArgumentException: Lint must be invoked with the System property com.android.tools.lint.bindir pointing to the ANDROID_SDK tools directory

In the terminal from the exact same folder I get after sbt compile..

[info] Loading global plugins from /Users/StramzCB/.sbt/0.13/plugins [info] Loading project definition from /Users/StramzCB/Desktop/sbt+intJ/hello-scaloid-sbt-master/project [info] Set current project to hello-scaloid-sbt (in build file:/Users/StramzCB/Desktop/sbt+intJ/hello-scaloid-sbt-master/) [info] Processing resources [success] Total time: 1 s, completed Jul 22, 2015 2:36:10 PM

Please help me on the proper current way of creating and android+sbt+intellij project. Otherwise I may have to resort to copying over source files into an sbt project just to compile an apk with, because of the 65k method limit.

3
Also, you do not build using intellij. Add a run configuration that executes android:package firstpfn
android update project is only for old ant-based buildspfn

3 Answers

0
votes
sbt gen-android

Import into intellij. Done

0
votes

Pre-requisite: Have your path set with all major sdk's, i.e. android,java, scala, sbt, maven, gradle. what ever you use.

What ended up working for me was not importing the gen-ndroid to intellij as an sbt project, but instead I was successful in the following..

1.Creating a new sbt Project with intellij Ultimate

2.Creating a submodule android project within the sbt project

3.Updating the android project with

: android update project -p .

: sbt gen-android-sbt // from the android-sdk-plugin for sbt

5.run some clean and compile commands in terminal to verify functioning

6.Open Sbt project with intellij and change run configurations to run sbt commands like

android:run

  1. It worked but my major problem was how my intellij sbt is not synched with my terminal sbt.

As far as plugins and registering resources it was laking compared to the terminal environment. Because of the issue I drop some unmanaged libraries for sbt, write in the ide for obvious reason and run sbt commands from terminal. Some libraries import but dont make it to the sub project so I use unmanaged libs, i.e. android.support.v4.

So far I don't have complaints as long as it compiles and gives me apks.

Here are my 2 days of wrathful resources to finally get a beast code environment. The whole reason I needed Sbt was for reducing package size.

https://github.com/pfn/android-sdk-plugin

http://macroid.github.io/ScalaOnAndroid.html

http://www.scala-sbt.org/0.12.2/docs/Getting-Started/Multi-Project.html

IntelliJ 14 - Create / Import a Scala / SBT project

https://github.com/pocorall/hello-scaloid-sbt

http://www.47deg.com/blog/scala-on-android-preparing-the-environment

How to get IntelliJ IDEA 14 working with Scala on Android (SBT)

0
votes

I have a solution that has worked only just recently for me and has been the best way to create a android sbt project in Intellij IDEA.

With pfn android sdk sbt plugin + SBT and Scala Plugin in intellij I did the following.

  1. Create a SBT Project
  2. Open terminal at project root and run sbt "gen-android android-21 com.some.your-pack testName"
  3. Now in Intellij a notification will notice the android template and then import the android template into your project
  4. This fixed a problem i had with the project name creating two overlapping modules, one named after package and one being the name