Ensime + sbt: "Android SDK not found" - android

I'm trying to use Ensime to work with adnroid project generated with g8 (https://github.com/philcali/android-plugin). Followed this question I added the android.jar to my .ensime file. Here is it:
(:project-package "org.test"
:use-sbt t
:compile-jars ("~/_dev/_android/android-sdk-linux_x86/platforms/android-8/android.jar"))
Also i've got an exported ANDROID_SDK_HOME variable in my ~/.bashrc file.
But when i'm trying to start the ensime i'm getting this error:
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)
I couldn't understand the reason why it happens. Does anybody have some thoughts about it? Thanks.

The solution is found! The answer is here: 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.
Thanks to zilti!

Related

Failed to update Android SDK Package List - Unity 2019.2.10f1

When I try to export the game build for the Android platform, I started getting this error:
Within the Project Settings - Minimum API Level and Target API Level not get loaded anyhow!
While I have used all default Unity provided settings to export Android build.
Here is the image to illustrate this:
Now what to do to solve this error?
I have already read all the threads related to same problem but overall I can't able to find the solution that actually worked for me.
Project Settings > Player > Target API Level: Change "Automatic" to "Android 11" (or else)
Play once and Stop.
Change target api level to Automatic.
I don't know if the problem is the same, but this is how I handle it every time.
Edit: Now I just do this; I open the Other Settings Tab in Player Settings. Error appears in console. I Play and Stop it once and the error goes away (No need to change API Levels)
I just got the same error on MacOS using both Unity 2019.4.18.f1/2019.2.21.f1 and after a lot of messing around I think I might have figured some of it out.
At times ( don't know why ) Unity ( or something else ) starts resetting the JAVA_HOME environment variable to string empty when you start Unity. So even if you set JAVA_HOME via console or .bashrc/.zshrc depending on MacOS version it still doesn't work.
Some posts mentioned adding "/" to the end of the external tools SDK path. I think that just forces Unity to set the path again which makes it work for a while. But for me the the error just came back the second day.
I permanently fixed it adding an editor script to the Editor folder that changes the JAVA_HOME environment variable every time Unity starts/loads.
Here's the method for MacOS, just paste it in a C# script in the editor folder.
[InitializeOnLoadMethod]
static void SetJavaHome()
{
//Debug.Log(EditorApplication.applicationPath);
Debug.Log("JAVA_HOME in editor was: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
string newJDKPath = EditorApplication.applicationPath.Replace("Unity.app", "PlaybackEngines/AndroidPlayer/OpenJDK");
if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
{
Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
}
Debug.Log("JAVA_HOME in editor set to: " + Environment.GetEnvironmentVariable("JAVA_HOME"));
}
This worked for me :- Edit>Prefrences>In JDK Click copy path> then Uncheck JDK and Paste the copied path again in that and after OpenJDK add \
like this : Before : C:\Program Files\Unity\Hub\Editor\2020.1.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
After : C:\Program Files\Unity\Hub\Editor\2020.1.3f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\
If that doesn't works than uncheck JDK,SDK,NDK,Gradle and Stop Gradle (all five boxes) than close unity. Open Again and Check all five boxes again.
I don't know why, but on mac os unity may use latest version of java if you have one.
If you have installed a few versions of java, you can just remove all except java v1.8.
You can check which version of java you have by typing in terminal /usr/libexec/java_home -V.
You should have 2 or more versions.
If you installed them with brew, you can just use brew to uninstall extra java packages.
Also you can update JAVA_HOME system variable by type
echo export "JAVA_HOME=$(/usr/libexec/java_home -v 1.8)" >> ~/.zshrc.
This solution worked for me.

ERROR android-emu/android/qt/qt_setup.cpp:28:Qt library not found at ..\emulator\lib64\qt\lib Could not launch 'C:\Users: No such file or directory

I am trying to work with the native native for a school project, but when executing the following command in cmd: emulator -version he returned this error to me:
[4640]:ERROR:android/android-emu/android/qt/qt_setup.cpp:28:Qt library not found at ..\emulator\lib64\qt\lib
Could not launch 'C:\Users\gusta..\emulator\qemu\windows-x86_64\qemu-system-i386.exe': No such file or directory
already changed the path in several ways and I think the problem is not this so if someone can help me grateful
There are two emulator executables in the sdk (as of now):
sdk/tools/emulator
sdk/emulator/emulator
The emulator executable has to be added in the PATH variable, in a way so that
sdk/emulator/emulator comes before sdk/tools/emulator
Do this to solve the error:
Edit the system environment variables
Make sure you have set user variable for ANDROID_HOME
Remove any variable /path/to/android-sdk/tools from user and system environment variable.
Save and exit
To resolve this error:
Your system variables should look like below:
“C:\Users\username\AppData\Local\Android\Sdk” -ANDROID_HOME
“C:\Users\username\AppData\Local\Android\Sdk\tools\bin” -PATH
“C:\Users\username\AppData\Local\Android\Sdk\platform-tools” -PATH
“C:\Users\username\AppData\Local\Android\Sdk\emulator” - PATH
“C:\Users\username\AppData\Local\Android\Sdk\tools" -PATH
This worked for me.
Based on the answer of IronBlossom.
On mac these are the important environment variables that need to be adjusted.
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
Make sure that emulator comes before tools

How to generate javadocs for android project

I followed all the instruction given on stackflow, but unfortunately not able to generate doc file for my android project.
If I am not mentioning class path on last step of java doc generation, then getting "Android reference" error.
And if using it, then getting "javadoc: error - The -classpath option may be specified no more than once." error.
Using classpath:
-classpath "D:\Android 4.2 SDK\android_sdk\platforms\android-15\android.jar"
Am I using correct class path command ?
Please help me out.
Environment used:
Eclipse indigo
If you use Intellij IDEA go to Tools - Generate JavaDoc... Specify all the settings and set params: -bootclasspath [path]\android-sdk\platforms\android-{version}\android.jar -encoding UTF-8 -docencoding utf-8 -charset utf-8
More information is in this post.
Have You followed these steps (from www.mtholyoke.edu)? This works on my Project....if not and You get an error, please write here which error You get.
Project -> Generate Javadoc
In the "Javadoc command" field - browse to find javadoc.exe
• On the computers in the Clapp CS lab that is C:\JBuilderX\jdk1.4\bin\javadoc.exe
• On other computers it would be \bin\javadoc.exe
Check the box next to the project/package/file for which you are creating the javadoc
In the "Destination" field browse to find the desired destination (for example, the root directory of the current project).
Leave everything else as it is.
Click "Finish"
Javadoc should be in the destination folder. Open "index.html"
EDIT
I found a thread here in Stackoverflow with a lot of tipps, try this:
Javadoc in Eclipse failing to recognize packages
NEXT EDIT
It is only a possibility, but You specified Your classpath as:
"D:\Android 4.2 SDK\android_sdk\platforms\android-15\android.jar"
I know that eclipse got some problems with spaces inside a path. So the first part "Android 4.2 SDK" has to be specified without spaces, maybe here is the issue. But be aware, if You change this path, You have to set everywhere the new path where You have definded it.
I'm using the command line. I have also updated to Eclipse Kepler. It seems to execute javadoc differently? I'm investigating. But try this:
read the javadoc manual. It's confusing and doesn't tell you what to do, but, here's an example that should get you going.
Create a file called "options"
Add to the file this:
-d target-bin
-stylesheetfile style.css
-use
-splitindex
-windowtitle 'My Project Name Class Specification'
-doctitle 'My Project Name Class Specification'
-header '<b>My Project Name</b><br><font size="-1">0.1.5-alpha</font>'
-bottom 'Copyright 2014 My Company or Myself. All rights reserved.'
-group "Group Of Packages" "com.mypackage.*"
-overview overview.html
-exclude 'android'
-subpackages 'com.mypackage:android'
-charset utf-8
-encoding UTF8
-quiet
-sourcepath ../myProject/src;..\..\..\android-sdks\sources\android-19
Then on the command line type:
javadoc #options
Now, in Kepler, the "Generate Javadoc" dialog box says "What is the javadoc command line"...I suspect I'll have to type something like this. But don't know.
Hopefully this quick example will give you a start on how to get it done for your purposes.
By the way, I created a generic Eclipse project called "javadoc" in my Workspace so I could manage the files.

Creating new, first, phonegap Android project on mac returns error: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1

I installed the all the recommended programs from PhoneGap's Getting Started Guide and followed the various steps.
I created the .bash_profile file and it looks like this:
export PATH=${PATH}:/Development/android-sdk-mac/sdk/platform-tools:/Development/android-sdk-mac/sdk/tools
The Development folder is located on my desktop. Upon navigating in terminal to my bin directory and creating a new PhoneGap project, i did like so:
./create /Users/joey/PhoneGapExample nl.symvoli.phonegapExample PhoneGapDemo
I get the following error:
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
I searched around what might cause this problem and everything seems to be pointing to value of the $PATH environment variable. When i ran echo $PATH in my terminal, it returns this:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Development/android-sdk-mac/sdk/platform-tools:/Development/android-sdk-mac/sdk/tools
Any help would be much appreciated.
I'm on a Mac, running Mac OSX 10.8.3
just command this in terminal/console
export PATH=${PATH}:"/Applications/Android Studio.app/sdk/tools":"/Applications/Android Studio.app/sdk/platform-tools"
check with echo $PATH and you show this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Applications/Android Studio.app/sdk/tools:/Applications/Android Studio.app/sdk/platform-tools
have you executed the ./create script with sudo?
if you run the script with sudo:
sudo ./create .....
you have another environment setted.
otherwise you have to export ANDROID_BIN variable
export ANDROID_BIN=/<your_android_sdk>/tools/android
I had the same issue. For me the issue was that I had set the PATH variable as described in step 3 of the tutorial, but I made a mistake and the PATH I specified was actually wrong.
So if it does not work with sudo, you might want to try and check the path again.
When I ran ./create I immediately received an error:
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
If you open up the create file (phonegap-2.7.0/lib/android/bin/create) with textEdit, there is a line that lists
ANDROID_BIN=”${ANDROID_BIN:=$( which android )}”.
The “which android” is the cause of the issue
If you replace this line with the full path to your android tools (SDK), it should resolve the issue. It looked like this:
ANDROID_BIN=/Users/cswjs/Documents/Dev/adt-bundle/sdk/tools/android
Hope this could help someone!
you can also try this
1.
open ~/.bash_profile
2.
export PATH=${PATH}:"/Users/**username_here**/Documents/adt-bundle-mac-x86_64-20131030/sdk/platform-tools:/Users/**username_here**/Documents/adt-bundle-mac-x86_64-20131030/sdk/tools"
3.
source ~/.bash_profile
Close Terminal, open Termial again and ...
just like found in here: http://yandr.randy.boy.jp/?eid=6
didn't understand a word but saw the last link and it worked for me :D
I've the same issue, in my configuration (mac pro + android studio) the sdk path was "/Applications/Android Studio.app/sdk". The problem is how you specify in "export $PATH=..." a new path added (/Application/Android Studio.app/sdk/tools and so on), seem that using '"' work with export $PATH for bash but does not work with script "create" with Phonegap. My end solution it's to move sdk in an alternative directory without blank in is name.
This is probably because of a wrong PATH. Refer this blog post

Android Virtual Device location error

I'm having a problem with starting an AVD from Eclipse.
When I start the AVD that I just created, it gives me the following error:
I think that is because of the username in the path...
I tried to just copy the .android to C:\ (=C:\.android) but the manager is just searching in the old path...
I tried to setup a environement variable like this:
Name: ANDROID_SDK_HOME
Value: C:\Users\André Peixoto\.android\.android
But it didn't solve the problem...
What should I try next?
UPDATE
I reinstalled the android sdk and now it doesn't show the weird characters:
But the path for the AVD_2_3_3.ini file still wrong. I think it should be: C:\Users\André Peixoto\.android\avd\AVD_2_3_3.ini instead of C:\Users\André Peixoto\.android\.android\.android/avd/AVD_2_3_3.ini
How should I change that?
I solved that using the solution presented on the comment 26 from here:
No matter your configuration. If the message will be like this
"[2011-11-21 22:31:24 - Emulator] PANIC: Could not open AVD config file: C:\Users\Ярослав.android\avd\my_defult_android_2_3_3_avd.avd/config.ini"
(
"C:\Users\Ярослав.android\avd\my_defult_android_2_3_3_avd.avd"
- it's your AVD device configuration. )
than :
copy direcoty "my_defult_android_2_3_3_avd.avd" to some place where the path will not contain "Ярослав" symbols (I in result had
the path like this
"d:\android\my_avd_devices\avd\my_defult_android_2_3_3_avd.avd").
File "my_defult_android_2_3_3_avd.ini" will contained in directory "C:\Users\Ярослав.android\avd\". Open this file.
Change "path=C:\Users\Ярослав.android\avd\my_defult_android_2_3_3_avd.avd" to
"path=d:\android\my_avd_devices\avd\my_defult_android_2_3_3_avd.avd"
Save and close. Start your application again))).
But at the first time I tried this solution and it didn't work. So I uninstalled the android SDK and eclipse and reinstalled all over again. I also removed the environments variables for android_sdk that I had previously set and set a new one called ANDROID_HOME with value C:\android-sdk.
Now I'm able to run AVD.
I think this is not a ideal solution because each time I create an AVD, I need to do this process. But for now it solves my problem.
Hope this solution helps someone else.
UPDATE - New Solution
I was having some problems with the previous solution so I used a diferent approach:
I created a new account (Administrator) in my Windows which the username havn't accents.
I put my Eclipse folder inside C:\ to have access from the new account.
Now, when I want to work with Android, I change to this new account.

Categories

Resources