3

我正在尝试使用 Ensime 处理使用 g8 ( https://github.com/philcali/android-plugin ) 生成的 adnroid 项目。按照这个问题 ,我将 android.jar 添加到我的 .ensime 文件中。就这个:

(:project-package "org.test"
:use-sbt t
:compile-jars ("~/_dev/_android/android-sdk-linux_x86/platforms/android-8/android.jar"))

此外,我的~/.bashrc 文件中有一个导出的ANDROID_SDK_HOME变量。但是当我尝试启动 ensime 时,我收到了这个错误:

java.lang.RuntimeException: Android SDK not found. You might need to set ANDROID_SDK_HOME or ANDROID_SDK_ROOT or ANDROID_HOME
    at scala.Predef$.error(Predef.scala:58)
    at AndroidPath$$anonfun$settings$8$$anonfun$apply$1.apply(AndroidPath.scala:21)
    at AndroidPath$$anonfun$settings$8$$anonfun$apply$1.apply(AndroidPath.scala:21)
    at scala.Option.getOrElse(Option.scala:104)
    at AndroidPath$$anonfun$settings$8.apply(AndroidPath.scala:21)
    at AndroidPath$$anonfun$settings$8.apply(AndroidPath.scala:20)
    at sbt.Scoped$Apply$$anonfun$single$1.apply(Structure.scala:444)
    at sbt.Scoped$Apply$$anonfun$single$1.apply(Structure.scala:444)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:44)
    at sbt.Init$Apply.get(Settings.scala:223)
    at sbt.Init$class.sbt$Init$$applySetting(Settings.scala:144)
    at sbt.Init$$anonfun$compile$1$$anonfun$3$$anonfun$apply$2.apply(Settings.scala:100)
    at sbt.Init$$anonfun$compile$1$$anonfun$3$$anonfun$apply$2.apply(Settings.scala:100)
    at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:123)
    at scala.collection.immutable.List.foldLeft(List.scala:45)
    at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:139)
    at scala.collection.immutable.List.$div$colon(List.scala:45)
    at sbt.Init$$anonfun$compile$1$$anonfun$3.apply(Settings.scala:100)
    at sbt.Init$$anonfun$compile$1$$anonfun$3.apply(Settings.scala:100)
    at sbt.Init$$anonfun$sbt$Init$$applyInits$1.apply(Settings.scala:140)
    at sbt.Init$$anonfun$sbt$Init$$applyInits$1.apply(Settings.scala:140)
    at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:123)
    at scala.collection.immutable.List.foldLeft(List.scala:45)
    at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:139)
    at scala.collection.immutable.List.$div$colon(List.scala:45)
    at sbt.Init$class.sbt$Init$$applyInits(Settings.scala:140)
    at sbt.Init$class.make(Settings.scala:92)
    at sbt.Project$.make(Project.scala:102)
    at sbt.Project$$anonfun$makeSettings$1.apply(Project.scala:177)
    at sbt.Project$$anonfun$makeSettings$1.apply(Project.scala:177)
    at sbt.Project$.translateCyclic(Project.scala:218)
    at sbt.Project$.makeSettings(Project.scala:177)
    at sbt.Load$.apply(Load.scala:120)
    at sbt.Load$.defaultLoad(Load.scala:36)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:371)
    at sbt.BuiltinCommands$$anonfun$loadProjectImpl$2.apply(Main.scala:368)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:61)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:61)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:63)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:63)
    at sbt.Command$.process(Command.scala:91)
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:66)
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:66)
    at sbt.State$$anon$1.process(State.scala:59)
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:66)
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:66)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:13)
    at sbt.MainLoop$.next(Main.scala:66)
    at sbt.MainLoop$.run(Main.scala:61)
    at sbt.xMain.run(Main.scala:33)
    at xsbt.boot.Launch$.run(Launch.scala:54)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:43)
    at xsbt.boot.Launch$.launch(Launch.scala:68)
    at xsbt.boot.Launch$.apply(Launch.scala:14)
    at xsbt.boot.Boot$.runImpl(Boot.scala:24)
    at xsbt.boot.Boot$.main(Boot.scala:15)
    at xsbt.boot.Boot.main(Boot.scala)

我无法理解它发生的原因。有人对此有什么想法吗?谢谢。

4

1 回答 1

2

解决办法找到了!答案在这里:https ://github.com/aemoncannon/ensime/issues/184#issuecomment-2038002 :

.bashrc 中的环境变量仅对在 bash 中运行或从 bash 启动的程序有效,否则您将需要 .profile。如果您使用的是 emacs:您可以使用 Mx getenv 查看 emacs 是否可以看到环境变量。在 .emacs 中使用 (setenv "ANDROID_SDK_HOME" "~/_dev/_android/android-sdk-linux_x86/") 为每个 emacs 会话设置它。但是您可能已经知道这一点,所以我不知道这是否有任何帮助。Emacs 有时似乎很难设置环境变量。

谢齐尔蒂

于 2011-09-08T09:20:10.713 回答