How to open .bashrc in Cygwin - android

When I try to compile my Android NDK program, it shows the following error:
Program "${SA}\android-ndk-r8\ndk-build.cmd" not found in PATH
(the value of the environment variable "SA" is C:)
I am using Cygwin on Windows 7. How do I open my .bashrc file? I read that I need to add the following lines to my .bashrc to fix the problem:
NDK_HOME=/opt/android-ndk-r8
export NDK_HOME
But I am not sure how to open .bashrc and edit the file as I have never done this before.

There are a number of text editors available under Cygwin, either installed by default or installable by using setup.exe.
vi/vim is probably the most common. It has a bit of a learning curve. Run vimtutor from your command line for a tutorial.
If you're very ambitious, you can try emacs. Run emacs from the command prompt, then Control-H t to run the built-in tutorial.
nano is a simpler and more user-friendly editor. It shows the most common commands at the bottom of the screen, including a help command. It may be the best one to start with.
You can use Windows editors like Notepad or Wordpad, but they're likely to add Windows-style end-of-line markers to any files you edit. You can use the dos2unix command (man dos2unix for more information) to fix that up, but IMHO that's more trouble than it's worth unless you really like Windows editors more than Unix-style editors.
The echo command in Henry's answer is a quick-and-dirty way to add a single line to a file. If you want to do anything more complex (say, deleting or changing lines, or adding lines other than at the very end), you'll need a real editor. To edit your .bashrc:
nano ~/.bashrc
(or use another editor of your choice).

You can do
echo "NDK_HOME=/opt/android-ndk-r8 export NDK_HOME" >> ~/.bashrc
be sure to restart your cygwin window afterwards

Related

AndroidStudio preferences vs shell path variables

I don't understand the difference between the path variables which you set in Android Studio Preferences which can be seen below and ones set in zshrc/bashrc.
I add this path in but when trying an ADB command, it is not recognized.
However, since i'm using zsh shell, same thing applies for bash. I add/export the PATH variable like i'm sure most people are familiar with.
As seen in last line, this is same path that was added to the AndroidStudio preferences, however now as you can see below. ADB is found!
What exactly is the
Android Studio -> Preferences -> Appearance&Behavior -> Path Variables?
Since it has KOTLIN_BUNDLED and im able to run kotlinc command in shell, it would make sense one could add ADB here but apparently not.
What is difference between these Path Variables and the Path Variables added to zshrc or bashrc?
PS: mirror is just an alias for an adb command

NDK-BUILD Not recognized as a command (Windows)

I know there is lot's of this question already however half of the just redirect to other questions and the others either tell me to stuff i tried, none of which worked.
The problem is i have been following this Tutorial. And the last step tell's me to use the ndk-build command, however when i try to run it i get this
'ndk-build' is not recognized as an internal or external command,
operable program or batch file.
I know i have the environmental path thing set right, and i did install cygwin and i did add it manually to the android program. So i do not know what the issue is. Any help would be much appreciated!
I also tried adding my ndk path to the System environment variables but the error was still there.
It worked for me by:
Opening command prompt and navigating to project
c:\eclipse\workspace\myproject
I then executed the ndk-build script from the android ndk folder
c:\eclipse\workspace\myproject> c:\android-ndk-r10e\ndk-build
I solved this issue by setting my NDK_HOME environmental variable and updating my path.
The $NDK_HOME on OSX or Linux (or %NDK_HOME% on Windows) points to the Android NDK Home Directory.
Then updating the PATH variable to include that directory and appending /build to the end of the path which solved the issue.
Not sure about cygwin (it sometimes makes windows-user-friendly exceptions), but on a real linux there are at least 3 gotchas:
1) the current directory is not searched for executables (at least by default)
2) You have to set the execute permissions on the files you want to execute, chmod a+x filename sets that permission, ls -l filename shows the permissions.
3) The disk may be mounted so that execution is not allowed.
4) file names are case-sensitive
which exefilename shows the full path of a command -- that is, if the system recognizes exefilename as executable.
Does it work if you provide the full path?
Does it work is you use source /full/path/to/ndk-build ?

Android is not recognized as an internal or external command - path variable

I'm having precisely the same issue as this person:
android' is not recognized as an internal or external command
However, I have also set the PATH environment variable (Windows 7) as recommended in the answer to the above post. In particular, I have:
C:\Users\p\AppData\Local\Android\android-sdk\tools
and
C:\Users\p\AppData\Local\Android\android-sdk\platform-tools
In addition, I have set %ANT_HOME%\bin and %JAVA_HOME%\bin. I have checked that the android.bat is indeed in the tools directory pointed to, that the PATHEXT variable contains ".bat", and I have restarted the command prompt. And yet 'android' is not recognized.
Does anyone have an idea what might be the problem? Many thanks in advance!
Find android.bat on your system. On mine (win 8 x64) it's under C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat
Open a command console, and use the 'doskey' command:
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
This will continue to work in the command console you executed the doskey command in. To make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
I do not know what causes the issue with the path variable.
However, the workaround I've used is to move to the "tools" directory and call android from there; I've added "--path " to point to the directory in which the project resides.
Details on how to manage android projects from the command line can be found here:
http://developer.android.com/tools/projects/projects-cmdline.html
You might have installed Cygwin as part of the SDK. I had the same problem "android.bat is not recognized as an internal or external command". So, Uninstall the Cygwin and try again (you might not able to uninstall Cygwin, since a mysterious “permission denied” when deleting the Cygwin files by default). You need to own access to this mysterious Cygwin files by taking ownership:
takeown /r /d y /f cygwin (do this, wherever is your cygwin folder is)
This command takes ownership recursive of the folder, without asking anything and gives Full Access to Everyone recursively in the folder:
icacls cygwin /t /grant Everyone:F
And finally, the command which deletes it all and removes Cygwin:
rmdir /s /q cygwin
Good bye Cygwin! ;-)
Now try again. (This worked for me)
PS: You can always re-install cygwin again. So, nothing wrong giving it a try. Good Luck
**Set the path in windows**
Control Panel\System and Security\System > advance system settings > environment variables
and update the path to include the following:enter code here
<android-root>\android-sdk-windows\tools
Use semicolons to separate paths in case yo have to add more path .

how to edit run.sh file in eclipse

I need to edit run.sh file in eclipse in windows. I'm following instructions in here, and I've installed the Android app completely and it's OK on my Xperia, however when it comes to building the host client part in the fourth line I don't know what run.sh does neither I know how to edit it,by the way, I guess it's a Linux file. And I have to say that I haven't installed CyanogenMod software as it is not Xperia p compatible according to it's website. The code in run.sh file in se.pki.client package, which I downloaded and imported previously, is as following.Althoug I've changed the code in the second line(giving it the path where my jdk is stored) while there's still an error in the first line saying the word "sh" is not correctly spelled and another error in the third line to
#!/bin/sh
JAVA_HOME=C:\ProgramFiles\java\jdk1.7.0\
$JAVA_HOME/bin/java -Dsun.security.smartcardio.library=/usr/local/lib/libpcsclite.so -cp bin/ org.nick.sepkiclient.Main $*
.sh files are the linux equivalent to a batch file. From the code you posted it just runs the java command (giving it a bunch of command line inputs) you should be able to run the same command in the windows terminal by just replacing the paths to windows paths. If there is more to the script than the 3 lines, you're going to needed to try and convert each line to a valid windows command (depending on the complexity of the script, this may not be possible.)
Your other option is to install software like Cygwin which adds a POSIX compliment shell (along with many other linux-ish modifications). This should allow you to run .sh files 'natively' in windows (it will require some fiddling with the script to provide the correct paths). Be sure you read about cigwin before you install it, it changes quite a lot about your system that you might not be comfortable with.
Each option has its drawbacks, and both require a little knowledge of shell scripting. Might just be easier to run Linux for what your doing (it behaves itself reasonably well in a VM).
Make sure you have it set as a unix file.
Window> Preferences>General>Workspace
Select line delimiter Other then Unix and test file encoding as UTF-8
As a last resort run dos2unix on the file from the shell.

Cannot use ndk-build on Cygwin

I have to use NDK for a clien't project. I am using Windows 7.
I followed the installation instructions. I have installed Cygwin 1.7.1.
In Cygwin bash, I go into the android NDK root directory.
When I see the contents of the directory, usin $dir command, I can see all the contents including ndk-build, but when I try to use ndk-build, this is the result I get:
$ndk-build
bash: ndk-build: command not found.
Not sure what I am doing wrong.
Cygwin emulates a GNU/Linux environment on your Windows computer. This means you're working with a "Shell" which is not exactly the same as the Windows command-line.
If you type asdf.exe in your Windows command-line, it tries to find asdf.exe in the current directory. If it can find it, the file is executed. If it can't find it, it'll go through every directory of your %PATH% and try again.
However, if you type asdf in your bash (there are multiple kind of shells, the Bourne Again SHell is one of them), it will not look after it in the current directory. Instead it'll try to find it in one of your PATH directories. Can't give you any sources here, but AFAIK it's for security reasons. If you want to run a file which is not in your PATH, you must prepend it with its absolute of relative path. You can use ./, it points to the current directory.
That's why you need to type ./ndk-build, because it's in the current directory and not your path. Something like /path/to/ndk/ndk-build will also work, but you have to type a bit more :).
(In fact it's even more complicated, if you want to execute a file, you need execute permissions for it. Google will help you if you have any problems with that.)

Categories

Resources