SDK.DIR is missing? android update project?

2019-03-08 10:23发布

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?

标签: android ant
10条回答
在下西门庆
2楼-- · 2019-03-08 10:30

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

查看更多
老娘就宠你
3楼-- · 2019-03-08 10:33

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>
查看更多
在下西门庆
4楼-- · 2019-03-08 10:33

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

查看更多
爷、活的狠高调
5楼-- · 2019-03-08 10:42

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

查看更多
迷人小祖宗
6楼-- · 2019-03-08 10:43

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 .
查看更多
叼着烟拽天下
7楼-- · 2019-03-08 10:44

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.

查看更多
登录 后发表回答