How to create sbt project using android module and run with Intellij ultimate?

I have been trying to create an android project in sbt like 2 days now and I am getting a lot of work. From the very beginning, I followed this tutorial only for creating sbt + android + intellij IDE project . which then directed me to android-sdk-plugin . I had to download sdks and install Paths before I could finally run the command sbt gen-android

to create an android project on the command line. However, when the android sbt project is created, the following cmd command line command android update project -p .

fails because the manifest is not in the root folder.

Troubleshoot by looking at type-safe pattern examples. So my fix is ​​to pass the manifest file and res to the sbt project root and move the android package to the src folder root to get the job done android update

. I got things to the point where my sbt project will compile in the terminal but not inside intellij after importing the same project.

Before starting this process, trying to build an sbt android project using IDE only, I was getting ANDROID_HOME to avoid getting compile time errors. Now that everything is set to PATHS and sdks, I get the following error when compiling sbt ..

[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 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 in the correct way to build and project android + sbt + intellij. Otherwise, I might have to resort to copying the source files into the sbt project in order to compile the apk due to the 65k method limitation.

+3


source to share


3 answers


I have a solution that only works recently for me and was the best way to create an sbt android project in Intellij IDEA.

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



  • Creating an SBT project
  • Open a terminal at the root of the project and run sbt "gen-android android-21 com.some.your-pack testName"
  • Now in Intellij, a notification will notice the android template and then import the android template into your project.
  • This fixed the problem I had a project name with, creating two overlapping modules, one called the package and one called the name
0


source


sbt gen-android

      



Import to intellij. Done

0


source


Prerequisite: point your path with all major sdk i.e. android, java, scala, sbt, maven, gradle. what are you using.

What ended up working for me did not import gen-ndroid for intellij as sbt project, but instead I succeeded in the following.

1.Create a new sbt project with intellij Ultimate

2.Creating android submodule project in sbt project

3.Delete android project with

: android update project -p.

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

5.run some clean and compiled commands in the terminal to test it works

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

android:run

  1. It worked, but my main problem was that my intellij sbt was out of sync with my terminal sbt.

As far as plugins and resource registration are concerned, this was compared to a terminal environment. Due to the problem, I throw some unmanaged libraries for sbt, write in ide for obvious reason, and run sbt commands from the terminal. Some libraries import but don't end up in the subproject so I am using unmanaged libraries i.e. Android.support.v4.

So far I have no complaints as long as it compiles and gives me the apks.

Here are my 2 days of angry resources to finally get the beast code environment. The whole reason I needed Sbt was to reduce the packet 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 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


source







All Articles