2011-09-07 76 views
3

我正在嘗試使用Ensime來處理與g8(https://github.com/philcali/android-plugin)生成的adnroid項目。跟着this question我將android.jar添加到我的.ensime文件中。下面是它:Ensime + sbt:「未找到Android SDK」

(: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) 

我不明白爲什麼會發生的原因。有人對此有一些想法嗎?謝謝。

回答

2

找到了解決方案!答案就在這裏:https://github.com/aemoncannon/ensime/issues/184#issuecomment-2038002

The environment variables in .bashrc are only valid for programs running in or are started from bash, otherwise you'll need .profile. If you're using emacs: You could use M-x getenv to see if emacs can see the environment variable. Use a (setenv "ANDROID_SDK_HOME" "~/_dev/_android/android-sdk-linux_x86/") in your .emacs to set it for every emacs session. But you probably already know this so I don't know if this is of any help at all. Emacs sometimes seems to be tricky to set up concerning environment vars.

由於zilti