I get this error when I do
$ ant release
sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
typing in android update project I get another error saying I must specify the path .... to the project.
Then I try cd into the directory of my project and do
android update -p .
android update -path .
etc and it says -p and -path are not globally recognized.
Could someone just give me the exact syntax?
cd to project directory and execute the following: The word project is part of the command, and is not to be replaced with an actual project name. The documentation does not make this clear and should be improved.
android update project -p .
You can use the command line argument for setting the sdk.dir, e.g:
ant -f xyz/build.xml clean release -Dsdk.dir=/Applications/adt-bundle-mac/sdk/
You can use sdk.dir in projet.properties file to define the sdk home or use an environment variable (more flexible for team work).
export ANDROID_HOME=<the path to your sdks>
You can inject the ANDROID_HOME environment variable into the sdk.dir property using the following ant command.
$ ant debug -Dsdk.dir=$ANDROID_HOME
ANDROID_HOME must be an absolute path such as /Users/jameswald/Development/android-sdk-macosx.
I had the same problem. After flailing around with the command line commands for a few minutes I ended up just editing the local.properties files directly.
You should have a file called local.properties within your
<app-directory>\platforms\android
folder. If you don't have one then you can create it.
Within the file there should be a reference that specifies where ant can find your android sdk. It should look like this:
sdk.dir=C:\\<path-to-sdk>\\sdk
Just update your details to point it to your correct android sdk folder.
The double \ are present in my file. Not sure why but it seems to work. :)
Note: this file also needs to be copied into your CordovaLib folder, which is one folder deeper: <app-directory>\platforms\android\CordovaLib
That should create/fix the local.properties from ant:
android update project --name --target
--path
name parameter is optional
target is the api version
More info here
https://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject
android update project -p . might fix your issue. Sometimes once you execute android update project -p . You might end up with a O/P Like this.
Updated local.properties
----------
build.xml: Failed to find version-tag string. File must be updated.
In order to not erase potential customizations, the file will not be automatically regenerated.
If no changes have been made to the file, delete it manually and run the command again.
If you have made customizations to the build process, the file must be manually updated.
It is recommended to:
* Copy current file to a safe location.
* Delete original file.
* Run command again to generate a new file.
* Port customizations to the new file, by looking at the new rules file
located at <SDK>/tools/ant/build.xml
* Update file to contain
version-tag: custom
to prevent file from being rewritten automatically by the SDK tools.
----------
Updated file ./proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.
If so try this command android update project -p . -s
the ANDROID_HOME must be set in the right context - just that you have it e.g. on your bashrc does not mean the var is set when you launch by clicking the icon ( bashrc doesn not get executed then - but when checking if the env var is set on the console it is )
you can also put it in the studio.sh:
#!/bin/sh
#
# ---------------------------------------------------------------------
# Android Studio startup script.
# ---------------------------------------------------------------------
#
export ANDROID_HOME=/home/ligi/bin/android-sdk/
message()
{
I had the same problem and it turned out that one of the ant scripts for some reason is referencing hard coded path to C:\ant and as my ant was in C:\apache-ant-{version} it could not find it. After renaming the ant directory everything worked fine.
For reference the file where I observed this issue was
\apache-ant-{version}\bin\ant.bat :line 106
Edit: I am using windows 8
Yeah, none of these solutions worked for me. This did from here:
Setting ANDROID_HOME enviromental variable on Mac OS X
Open the terminal window and enter the following (I hope this is the complete path to sdk):
export ANDROID_HOME=/Applications/ADT/sdk
Once you have this set, you need to add this to the PATH environment variable
export PATH=$PATH:$ANDROID_HOME/bin
Related
I have seen this same thing posted quite a few times, but whenever I try to import my project to my new work laptop I keep getting this error.
I have pulled the project from git (which his btw running fine on my old laptop).
Then I went to the sdk manager, downloaded all the tools, and all the SDK's available.
In the welcome screen, I went to Configure -> project Defaults -> Project structure.
Android SDK Tab says the path for projects without local.properties will be /Applications/Android Studio.app/sdk
This is correct.
Under SDKs I have all the available SDK's visible.
Project SDK is set to API 18
Yet still I get this error when trying to build my project.
Can anyone tell me where I havent looked yet?
I am running gradle 1.7 when trying to build which is downloaded from services.gradle.org
I had very similar situation (had a project on another machine and cloned it to my laptop and saw the same issue) and I looked in it.
Error message was coming from Sdk.groovy of Android gradle plugin:
https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/Sdk.groovy
By looking at code, its findLocation needs to set androidSdkDir variable and there are only three ways to do it:
create local.properties file and have either sdk.dir or android.dir line.
have ANDROID_HOME environment variable defined.
System.getProperty("android.home") - I'm not sure how it works, but it seems like a Java thing.
While your Android Studio knows that the SDK is at that place, I doubt that Android Studio is passing that information to gradle and thus we're seeing that error.
I created local.properties file at the project root and put the following line and it compiled the code successfully.
sdk.dir = /Applications/Android Studio.app/sdk/
creating local.properties file in the root directory solved my issue
I somehow lost this file after pulling from GitHub
this is how my local.properties file looks like now:
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sat Feb 06 11:53:03 EST 2016
sdk.dir=/Users/****/Library/Android/sdk
I found the solution here:
http://xinyustudio.wordpress.com/2014/07/02/gradle-sdk-location-not-found-the-problem-and-solution/
Just create a file local.properties and add a line with sdk.dir=SDK_LOCATION
If none of the answers work for you which happened to me on macbook pro in one of the projects you can always try to run Android Studio with an alias command passing sdk.dir with each run:
alias studio='launchctl setenv ANDROID_HOME '\''/Users/username/Library/Android/sdk'\'' && open -a '\''Android Studio'\'''
To fix this problem, I had to define the ANDROID_HOME environment variable in the Windows OS.
To do this, I went to the System control panel.
I selected "Advanced system settings" in the left column.
On the "Advanced" tab, I selected "Environment Variables" at the bottom.
Here, I did not have an ANDROID_HOME variable defined. For this case, I selected "New..." and:
1) for "Variable name" I typed ANDROID_HOME,
2) for "Variable value", I typed the path to my SDK folder, e.g. "C:\...\AppData\Local\Android\sdk".
I then closed Android Studio and reopened, and everything worked.
Thanks to Dibish (https://stackoverflow.com/users/2244411/dibish) for one of his posts that gave me this idea.
Had the same problem in IntelliJ 12, even though I have ANDROID_HOME env variable it still gives the same error. I ended up creating local.properties file under the root of my project (my project has a main project w/ a few submodules in its own directories). This solved the error.
specifying sdk.dir=<SDK_PATH> in local.properties in root folder solved my problem.
I clone libgdx demo, can't import project. it also reminds like this.
Env:
Eclipse(Android-ADT)
window 7
so I create local.properties file at the project root, like following
sdk.dir = D:/adt-bundle-windows-x86/sdk
I hope this can help others!
Copy and paste the local.properties file from a project you created on your new computer to the folder containing the project from your old computer also works too if you don't want to (or know how to) create a new local.properties file.
I noticed that I get this error when I'm working on a new computer if I try to build from the command line first. However, if I build from Android Studio, it retrieves the SDK and creates the directory automatically. Then when I build from the command line it works.
You have also to ensure you have the correct SDK platform version installed in your environment by using SDK Manager.
If you have cloned a project from GitHub for example, and you've tried the methods mentioned here without success including:
Editing sdk.dir in the local.properties
Trying to set ANDROID_HOME environment variable
Or adding an alias as kasiara mentioned
You should try to see if you are trying to build a directory project that is a part within a bigger project, and so it may cause problems.
So load the entire project, and then run the project directory you'd like.
In my specific case I tried to create a React Native app using the react-native init installation process, when I encountered the discussed problem.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\***\android\local.properties'.
I add this, because when developing an android app using react native, the 'root directory' to which so many answers refer, is actually the root of the android folder (and not the project's root folder, where App.js resides). This is also made clear by the directory marked in the error message.
To solve it, just add a local.properties file to the android folder, and type:
sdk.dir=C:/Users/{user name}/AppData/Local/Android/Sdk
Be sure to add the local disk's reference ('C:/'), because it did not work otherwise in my case.
I want to set up a ant build for my project. I found a tutorial saying that I need to write the following command in order to prepare for ant build:
android update project -p
then I get the result
Updated local.properties
Updated file ./proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.
so If I try
android update project -p . --subprojects
then I get:
Updated local.properties
Updated file ./proguard-project.txt
Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android update' command.
and if I try
ant release
I get
sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
Can some one please help me in setting up the project with ant.
Thanks
I also had the same problem.
My problem problem got solved by the following command.
android update project --path . --subprojects --target android-19
ANT will automatically set your sdk.dir into correct one.
Don't put anything inside your local.properties.
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
Be sure to have a target set in your projects (main project and libraries as well).
on Eclipse:
Right click on the project -> Properties -> Android and select your target SDK. This means the Android SDK version you are targeting. If you take a look in the manifest.xml, you should see that almost at the beginning:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
This is the target version for your project, and usually is recommended to be as highest (newest) as possible.
After that, be sure that the file project.properties has a line similar to this one:
target=Google Inc.:Google APIs:17
This file will be read by ANT to know the target of your project. You can add that line manually. Actually, I'm pretty sure that will be included automatically if you set the target for the projects in Eclipse (as I said above) before running android update project -p . --subprojects
About this error:
sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
It means you didn't define the sdk.dir property, which should point to the android sdk root directory in your file system. After running android update project -p . --subprojects it should be generated automatically for all your projects. It's possible that it wasn't due to the previous error. So check all your projects for the file called local.properties and be sure that contains a line similar to this:
sdk.dir=/home/path/to/android/sdk/android-sdk-linux
I'm trying to build an app (let's call it android-app) with a dependency on an SDK (let's call it sdk) via Ant. Eclipse is not installed on this computer (for reasoning, it's a CI box with Jenkins).
Both projects are in two completely separate directories side by side. android-app is in the directory ~/.jenkins/jobs/android-app/workspace and sdk is in the directory ~/.jenkins/jobs/sdk/workspace.
Let's assume both projects are "vanilla" and have not been built with Ant before. I cd to the ../android-app/workspace directory and run android update project -p . --library ~/.jenkins/jobs/sdk/workspace which passes. I then cd to the ../sdk/workspace directory and run android update project -p . which also passes.
At this point I cd back to the ../android-app/workspace directory and run ant clean build. It fails with the error:
BUILD FAILED
/path/to/ant/build.xml:440:
/path/to/sdk/workspace resolve to a path with no project.properties file for
project /path/to/android-app/workspace
... where /path/to is the full path to the directories. I simplified it here.
If I cd to the sdk workspace and open project.properties, I receive the following:
# ProGuard
proguard.config=proguard.cfg
# Project target.
target=android-10
android.library=true
It does exist. So do all of these files:
So, why is this failing? What am I doing wrong? I tried to provide as many details as possible. Please let me know if I can provide anything additional.
Well, I encounter this problem too.
I use strace to find out what the hell is going on and found that the path you specified in project.properties will be appended with your current folder path as its prefix.
For example,
/home/myfolder/project > ant debug
And the library you specified in project.properties is /path/to/library
Then, the path will become
/home/myfolder/project/path/to/library
Just to fill in the answer gap here, my Java version was completely off. I'm super embarrassed.
I'm new to development with the NDK of Android.
As I'm developing on Win7 I installed Cygwin in order to build the native binaries.
When running ndk-build from the project folder /home/simon/ndk/hello-neon I get the error
ERROR: You are using a non-Cygwin compatible Make program.
Currently using: C:/Programs/cygwin/bin/make
To solve the issue, follow these steps:
1. Ensure that the Cygwin 'make' package is installed.
NOTE: You will need GNU Make 3.81 or later!
2. Define the GNUMAKE environment variable to point to it, as in:
export GNUMAKE=/usr/bin/make
3. Call 'ndk-build' again.
The problem that stops me now is that the ndk-build script seems not to be able to call the check-cygwin-make.mk script in the following lines:
GNUMAKE=`cygpath -u $GNUMAKE`
PROGDIR_MIXED=`cygpath -m $PROGDIR`
CYGWIN_GNUMAKE=`$GNUMAKE -f "$PROGDIR_MIXED/build/core/check-cygwin-make.mk" 2>&1`
When calling
echo $CYGWIN_GNUMAKE
I get the reply:
make: C:/Programs/cygwin/home/simon/build/core/check-cygwin-make.mk: No such fil
e or directory make: AndroidManifest.xml build.properties default.properties jni
res src No rule to make target `C:/Programs/cygwin/home/simon/build/core/check-
cygwin-make.mk'. Stop.
Now I'm lost because I don't understand the role of the check-cygwin-make.mk script and I could not find it anywhere on my drive.
I'm aware of the problem with spaces in the C:/Program Files/ folder name, and I think this is not problem now.
I hope someone can help my to solve this issue,
Regards,
Simon
Install android-ndk and cygwin(with "make" support command) then set the varaibles like this
Right-click My Computer, and then click Properties.
Click the Advanced tab.
Click Environment variables.
then edit"PATH" add this line
C:\cygwin\bin like this
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files......;C:\cygwin\bin
then try with your built steps
'check-cygwin-make.mk' is in '\android-ndk-r6b\build\core', and you should have installed Android NDK to a directory without spaces in the path.
Next you should be running ndk-build either from Cygwin-shell, or with the command 'bash -c ndk-build'.
And of course the necessary paths both to Cygwin binaries (as in the previous answer), and to ndk-build should be specified in PATH.
I am trying to make ndk-build to work within Cygwin on windows. As per the NDK documentation (specifically INSTALL.htm), "The NDK requires GNU Make 3.81 or later being available on your development."
I have Gnu Make installed on my computer.
So far, so good.
Within Cygwin bash, I cd over to the android NDK root directory. Now when I type in the following command (without parameters right now, just to see if the command works):
$./ndk-build
ERROR: Cannot find 'make' program. Please install Cygwin make package or define the GNUMAKE variable to point to it.
So I try to set the GNUMAKE variable, but no luck:
$export GNUMAKE='/cygdrive/c\Program Files\GnuWin32\bin'
ERROR: Your GNUMAKE variable is defined to an invalid name: /cygdrive/c\Program Files\GnuWin32\bin
Please fix it to point to a valid make executable (e.g. usr/bin/make)
I even tried setting it to usr/bin/make as it suggests, but same invalid name error.
Anyone, knows how to resolve this?
I'm using Windows 7, NDK r5, Cygwin 1.7.1
I had an issue with GNUMake when putting the ndk in a folder with a space in it (I originally put it in the program files directory). I moved everything to C:/android/android-ndk and C:/android/android-sdk and updated my path settings to include these directories.
Its not problem with the make but installing cygwin
in ndk-demo script the make path is found using which command mostly which command
installation is missing in cygwin.
Solution:
Relaunch your cygwin installation select utils (install )
Checking:
$ which make
should give you the make command path on cygwin prompt.
Regards,
Vasu
This is a generic error. It means there was a problem somehow with the make command, but the error message itself is hidden. To help diagnose the problem, open your ndk_build script in the ndk directory, and change these lines:
ABS_GNUMAKE=`which $GNUMAKE 2> /dev/null`
...
GNUMAKE=`which make 2> /dev/null`
to these:
ABS_GNUMAKE=`which $GNUMAKE`
...
GNUMAKE=`which make`
And then you will get a more detailed error message. Note that it might not even be a problem with the 'make' command, it might be a problem with the 'which' command. Make sure you have cygwin installed.
delete Environmental variable GNUMAKE
close the cygwin terminal
open again cygwin terminal... go the path where u want to build.. and now build it...
I am sure hopefully you will build successfully..as i do..
The answer with moving NDK to a directory without spaces is definitely right. After that you will probably able to run ndk-build from the Cygwin shell.
However running ndk-build from Windows commmand line (like "bash ndk-build") will probably cause the same queer error with "incorrect GNU make".
It is reproducible with NDK 6b as well.
And I hope it is fixed in the newest version of NDK...
ERROR: Cannot find 'make' program. Please install Cygwin make package
or define the GNUMAKE variable to point to it.
While trying to install Cygwin i missed out to install MAKE PACKAGE
Just need to search make in the Search box and it will shows the Branches that includes devel branch and from devel branch i selected make package.
That's all issue fixed.
i worked hard on error in gygwin terminal "gnumake variable is define to invalid name" and after that i get to the point that we simply remove this error by deleting the GNUMAKE path in environment variable both in system and user variable if u created it hope its helps....
mycomputer > system properties > advanced system setting > environment variable
The problem here is the name of the GNUMAKE variable.The name given was
/cygdrive/c\Program Files\GnuWin32\bin change it into /cygdrive/c/Program Files/GnuWin32/bin/make
only use forword Slash .Sometime the space in the folder structure does not taken
Happy coding.