【问题标题】:How to create sbt project with an android module and run with Intellij ultimate?如何使用 android 模块创建 sbt 项目并使用 Intellij Ultimate 运行?
【发布时间】:2015-10-12 19:40:44
【问题描述】:

我已经尝试在 sbt 中创建一个 android 项目已经有 2 天了,而且我经常跑来跑去。从一开始我就一直在关注本教程来创建sbt+android+intellij IDE project。然后将我引向android-sdk-plugin。在我最终能够执行sbt gen-android 命令在命令行中创建一个android 项目之前,我必须下载sdks 并设置路径。但是,当创建 android sbt 项目时,以下 cmd 行命令 android update project -p . 不会执行,因为清单不在根文件夹中。

我通过查看类型安全的 scaloid 模板示例进行了故障排除。因此,我的解决方法是将清单文件和 res 文件都传输到 sbt 项目的根目录,并将 android 包移动到 src 文件夹的根目录,以使 android update 工作。在导入同一个项目后,我的 sbt 项目将在终端中编译,而不是在 intellij 中编译。

在开始此过程之前,尝试仅使用 IDE 创建一个 sbt android 项目,但我在编译期间遇到 ANDROID_HOME not set 错误。现在一切都设置为 PATHS 和 sdks 之后,我在 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

在终端中来自我在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

请帮助我正确创建和 android+sbt+intellij 项目的当前方式。否则,由于 65k 方法限制,我可能不得不求助于将源文件复制到 sbt 项目中来编译 apk。

【问题讨论】:

  • 另外,您不使用 intellij 构建。添加一个运行配置先执行android:package
  • android 更新项目仅适用于旧的基于 ant 的构建

标签: android scala intellij-idea sbt


【解决方案1】:
sbt gen-android

导入intellij。 完成

【讨论】:

    【解决方案2】:

    先决条件:使用所有主要的 sdk 设置路径,即 android、java、scala、sbt、maven、gradle。你用什么。

    最终为我工作的不是将 gen-ndroid 作为一个 sbt 项目导入到 intellij,而是我在以下方面取得了成功..

    1.使用 intellij Ultimate 创建一个新的 sbt 项目

    2.在sbt项目中创建子模块android项目

    3.更新android项目

    :android更新项目-p。

    : sbt gen-android-sbt // 来自 sbt 的 android-sdk-plugin

    5.在终端运行一些干净和编译命令来验证功能

    6.使用 intellij 打开 Sbt 项目并更改运行配置以运行 sbt 命令,如

    android:run

    1. 它有效,但我的主要问题是我的 intellij sbt 与终端 sbt 不同步。

    就插件和注册资源而言,与终端环境相比,它缺乏。由于这个问题,我为 sbt 删除了一些非托管库,出于明显的原因在 ide 中写入并从终端运行 sbt 命令。一些库导入但没有进入子项目,所以我使用非托管库,即 android.support.v4。

    到目前为止,只要它编译并给我 apk,我就没有抱怨。

    这是我这2天的怒气资源,终于搞定了一个兽码环境。我需要 Sbt 的全部原因是为了减小封装尺寸。

    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)

    【讨论】:

    • sbt "gen-android android-22 com.example.app Hello",进入 IntelliJ,导入 -> 将平台 SDK 设置为 Android 22,启用自动导入。它应该在那个时候工作。从那时起只需使用 sbt 构建,否则,所有突出显示和 IDE 功能都应该在 IntelliJ 中正常工作。
    • 再次对我不起作用。导入后我收到此消息.. Error:Cannot determine Java VM executable in selected JDK
    【解决方案3】:

    我有一个最近才对我有用的解决方案,它是在 Intellij IDEA 中创建 android sbt 项目的最佳方式。

    在 intellij 中使用 pfn android sdk sbt plugin + SBT 和 Scala 插件,我做了以下事情。

    1. 创建 SBT 项目
    2. 在项目根目录打开终端并运行 sbt "gen-android android-21 com.some.your-pack testName"
    3. 现在在 Intellij 中,通知会注意到 android 模板,然后将 android 模板导入您的项目中
    4. 这解决了我在项目名称创建两个重叠模块时遇到的问题,一个以包命名,一个以名称命名

    【讨论】:

      猜你喜欢
      • 2011-05-14
      • 1970-01-01
      • 2016-06-02
      • 1970-01-01
      • 2023-03-18
      • 2018-07-23
      • 1970-01-01
      • 2018-02-09
      • 2016-04-13
      相关资源
      最近更新 更多