Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Cygiwn path problem

Options
  • 13-11-2012 5:43pm
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭


    Hi I installed cygwin but am having trouble with paths. I have to set a variable to the android sdk path for a script to work. I do that, however it says that it can not find it? I know it is there and working fine. Am I setting the variable path wrong? it spits out the path I want as an error when it says it cant find it at that location?! If I type in that path it even works, so am quite confused.

    gPUuQ.png

    Script contents:
    #!/bin/bash
    # You have to run this once in order for ant builds to work
    set -e
    
    if [ -z "${ANDROID_SDK_ROOT+xxx}" ]; then
    	echo "Please define ANDROID_SDK_ROOT to point to the Android SDK"
    	exit 1
    fi
    
    if [ ! -d "$ANDROID_SDK_ROOT" ]; then
        echo "The directory $ANDROID_SDK_ROOT = ${ANDROID_NDK_ROOT} does not exist."
        exit 1
    fi
    
    ANDROID="$ANDROID_SDK_ROOT/tools/android"
    
    command -v "$ANDROID" >/dev/null 2>&1 || { echo >&2 "The $ANDROID tool is not found.  Aborting."; exit 1; }
    
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    ATE_ROOT="$( cd $DIR/.. && pwd )"
    
    echo "Updating android project files"
    
    PROJECT_FILES="$( find "$ATE_ROOT" -name project.properties )"
    
    for PROJECT_FILE in $PROJECT_FILES
    do
        PROJECT_DIR="$( dirname "$PROJECT_FILE" )"
        $ANDROID update project -p "$PROJECT_DIR"
    done
    


Comments

  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    Hi I installed cygwin but am having trouble with paths. I have to set a variable to the android sdk path for a script to work. I do that, however it says that it can not find it? I know it is there and working fine. Am I setting the variable path wrong? it spits out the path I want as an error when it says it cant find it at that location?! If I type in that path it even works, so am quite confused.

    gPUuQ.png

    Script contents:
    #!/bin/bash
    # You have to run this once in order for ant builds to work
    set -e
    
    if [ -z "${ANDROID_SDK_ROOT+xxx}" ]; then
    	echo "Please define ANDROID_SDK_ROOT to point to the Android SDK"
    	exit 1
    fi
    
    if [ ! -d "$ANDROID_SDK_ROOT" ]; then
        echo "The directory $ANDROID_SDK_ROOT = ${ANDROID_NDK_ROOT} does not exist."
        exit 1
    fi
    
    ANDROID="$ANDROID_SDK_ROOT/tools/android"
    
    command -v "$ANDROID" >/dev/null 2>&1 || { echo >&2 "The $ANDROID tool is not found.  Aborting."; exit 1; }
    
    DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
    ATE_ROOT="$( cd $DIR/.. && pwd )"
    
    echo "Updating android project files"
    
    PROJECT_FILES="$( find "$ATE_ROOT" -name project.properties )"
    
    for PROJECT_FILE in $PROJECT_FILES
    do
        PROJECT_DIR="$( dirname "$PROJECT_FILE" )"
        $ANDROID update project -p "$PROJECT_DIR"
    done
    

    I dont have an answer, but am extremely curious why you want to do this?


  • Registered Users Posts: 163 ✭✭stephenlane80


    Why are you running the script from a dos terminal, use the bash terminal that gets installed with cygwin. The bash terminal used path names in the format "/cygdrive/.....", the dos terminal used "C:\.......".When you run a bash script in a dos terminal you are mixing the path types.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    Thanks Stephen, I'll try it out in the cygwin terminal, I was just wondering why it printed out the correct path and didn't work. So cygwin is actually necessary for this, you can't use dos alone. I was a bit confused about how integrating cygwin commands into dos was affecting it.
    ChRoMe wrote: »

    I dont have an answer, but am extremely curious why you want to do this?
    I'm just trying to build an android project in windows and was trying out cygwin out of curiousity, I don't think you need it these days with the ndk anyway. May do to run this script


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    Thanks Stephen, I'll try it out in the cygwin terminal, I was just wondering why it printed out the correct path and didn't work. So cygwin is actually necessary for this, you can't use dos alone. I was a bit confused about how integrating cygwin commands into dos was affecting it.
    I'm just trying to build an android project in windows and was trying out cygwin out of curiousity, I don't think you need it these days with the ndk anyway. May do to run this script

    I presume you are using Eclipse and the ADT... if so it automatically does all the building for you.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    ChRoMe wrote: »
    I presume you are using Eclipse and the ADT... if so it automatically does all the building for you.

    I am, generally you would be correct, however this project needs to be built using Ant/ndk-build tools and you must run a setup script
    to set up the local.properties files for all the ant projects.


  • Advertisement
  • Registered Users Posts: 7,157 ✭✭✭srsly78


    Android ndk uses cygwin.

    Try using export instead of set, also use proper bash as other poster suggested.

    Test that your variable is set correctly like this: echo $ANDROID_SDK_ROOT


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    I used cygwin and got the same thing, path is set right when I echo it. Very strange. Works fine in Ubuntu.

    I don't understand why it has no problem detecting the sdk path but then doesnt find the file inside it.


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    How do you know your path is set right? What test are you using? Just echoing it may not be enough. You can try editing the bash script to put more echos in, or put "export" on it's own in the script, and it will print out all its vars. You can use a normal dos prompt IF you have $CYGWIN/bin in your path. Opening a "cygwin terminal" just automatically sets this I believe.

    One gotcha with the windows path variable is it will not use the last bit if you end it with a space or a ;... Or something like that, can't remember exactly -.-

    Oh, you need to define TWO variables. One for android sdk, and another for android ndk. They are seperate downloads (when I tried it in the past anyway), and you could have them in 2 totally different folders.

    Also, it's fine to use "C:" syntax. Cygwin is just giving you a warning about it, it will work tho. Problem arises when you try to use your "C:" on linux tho.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    srsly78 wrote: »
    How do you know your path is set right? What test are you using? Just echoing it may not be enough. You can try editing the bash script to put more echos in, or put "export" on it's own in the script, and it will print out all its vars. You can use a normal dos prompt IF you have $CYGWIN/bin in your path. Opening a "cygwin terminal" just automatically sets this I believe.

    One gotcha with the windows path variable is it will not use the last bit if you end it with a space or a ;... Or something like that, can't remember exactly -.-

    Oh, you need to define TWO variables. One for android sdk, and another for android ndk. They are seperate downloads (when I tried it in the past anyway), and you could have them in 2 totally different folders.

    Also, it's fine to use "C:" syntax. Cygwin is just giving you a warning about it, it will work tho. Problem arises when you try to use your "C:" on linux tho.
    I was guessing that it was set right because of the echo and also because it does not complain that the path does not exist. For example if I stick in a path of C:/Users/paul/android-sdks2 instead, it will say that that path will not exist when I run update.sh, it never gets as far as the tool error. I can try and stick some print statements in the file like you say.

    I do have cygwin in my path so I thought it would work in dos, seems it would, as I am getting the same error in both.

    Yeah I realise I have to set another variable after this one thanks, just I can't get that far in the scripts. I do have the ndk files ready as well.

    Will give that stuff a shot now and see what it says thanks.


    might it be something got to do with it being called android.bat and not android?


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    If your vars are set right you should be able to just type into command line: $ANDROID_SDK_ROOT\tools\android

    Get that working and script will work. I have android sdk here and I can see android.bat target present. (it will default to look for bats or exes etc)

    Oh yeah, try using the other slash :D

    Execute this:

    export ANDROID_SDK_ROOT=c:\users\paul\android-sdks
    $ANDROID_SDK_ROOT\tools\android


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    If I type $ANDROID_SDK_ROOT/tools/android nothing happens, if I type $ANDROID_SDK_ROOT/tools/android.bat it loads fine.


    If I type the path without .bat into dos that loads?!

    I'm double backslashing and all for the craic\\


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    .sh files really dont like to be edited in word!
    $ ./update.sh
    : invalid optione 3: set: -
    set: usage: set [--abefhkmnptuvxBCHP] [-o option-name] [arg ...]
    ./update.sh: line 4: $'\r': command not found
    ./update.sh: line 27: syntax error near unexpected token `$'do\r''
    '/update.sh: line 27: `do
    


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    Try just running ./update.sh. Then the normal dos interpreter should run it and it will know about bat files. edit: From a dos window! Not from a shell running inside a dos prompt -.-

    Download notepad++ for editing stuff like this.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    Had tried that but apparently not all cygwin commands are able to be used so ill have to try and fix that.
    '.' is not recognized as an internal or external command,
    operable program or batch file.
    

    So annoying!


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    What exactly is this script for? I don't see anything about this in the install guide.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    It's for building a particular project, I can get other projects/android working fine

    https://github.com/jackpal/Android-Terminal-Emulator/blob/master/docs/Building.txt

    I thik the solution is to actually just edit the script, will have to get some editor that doesn't break it when I save it...


  • Registered Users Posts: 7,157 ✭✭✭srsly78


    I think that script is out of date, the official ndk has changed the way it does stuff. Yeah you will have to hack it together.

    Install gvim package for cygwin for good editor!


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    Thanks I'll install that. Very annoying as it took 2 seconds in ubuntu and has taken over 2 evenings in windows, god dammit windows. Thanks very much for your help!


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    Thanks I'll install that. Very annoying as it took 2 seconds in ubuntu and has taken over 2 evenings in windows, god dammit windows. Thanks very much for your help!

    I'm not really surprised tbh, running a Unix VM is always faster than cygwin messing about


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,092 Mod ✭✭✭✭Tar.Aldarion


    Yeah I should ahve jsut done that tbh.


    Finally got it working now by editing the script, making it 'half run' in cygwin, get some errors about files. Couldn't run that bit in dos... Run the rest of it in dos, hey presto, it works...my lord.


  • Advertisement
Advertisement