How to add platform android (cordova) on Mac - android

i have follow the instructions.phonegab docs and How to add android to cordova platform? PATH error?
my .bash_profile:
export PATH=/usr/local/bin:$PATH
export PATH=$PATH:~/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
export PATH=${PATH}:~/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:~/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
eval "$(rbenv init -)"
but still Error while i executing cordova platform add android or ionic platform android:
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
Any Solutions? thank you

Try to run android in command line. if the command is not found, it's mean that the path of android sdk that registered is still wrong

AndroidDev PATH
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
You have to manually reload your setting like for Ubuntu I am using this command "$ source ~/.bashrc"

Thank you All for your clue of solutions. I try add $HOME because /Development directory in /Home directory and i followed code RVM in my .bash_profile:
`[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
eval "$(rbenv init -)"`
The solutions in How to add android to cordova platform? PATH error? i followed symbol ~ for initialize /Development directory in /Home directory, but it's not working. and I try follow code RVM in my .bash_profile use $HOME.
this is my .bash_profile:
export PATH=${PATH}:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
eval "$(rbenv init -)"
and then run command source ~/.bash_profile. Solved

Related

React Native packager.sh: line 11: node: command not found

I initiated a new project with Create-React-Native-App and then ejected from the project. I followed the instructions for the React-Native docs I opened up a virtual device on Android Studio and ran yarn android to build the app. I then get this error message:
I'm currently using Node 8.11.1 and the command is working normally on my terminal. I installed it with NVM.
In the packager.sh file, this is what line 11 is:
node "./local-cli/cli.js" start "$#"
Here are my .bashrc and .bash_profile files:
.bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
.bash_profile
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
source ~/.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
In the virtual device, I get the error message: Unable to load script from assets index.android.bundle. Make sure your bundle is packaged correctly or you're running a packager server
I've found two questions on here related to this problem but one of them was using Nuclide and the other guy was using Xcode. Can someone please help with this issue?
Answer and discussion from: https://github.com/realm/realm-js/issues/1448#issuecomment-340757479
The default shell that is opened to run this command doesn't have the NVM node in its PATH. The solution given is to link the existing node install to where the shell expects it to be:
ln -s $(which node) /usr/local/bin/node
I was facing the same issue and was using nvm. What I need to do is
nvm alias default v8.15.1
Just to update with someone still having this problem.
I tried all above solutions answer above (and some suggestions from github as well), but neither of them worked for my case (I'm using nvm and node v10.15.3 (TLS))
The final solution I found was to uninstall both nvm & nodejs, then reinstalled nodejs without using nvm via https://nodejs.org/en/download/.
And it works!
You can try running below command:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Reference

React Native adb reverse ENOENT

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync
Here is a log
JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.785 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.
I found my android emulator when executing adb devices
List of devices attached
192.168.56.101:5555 device
I have tried the following steps from Stack Overflow post, but still no luck
https://stackoverflow.com/a/38536290/4540216
I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.
Follow this React-native android-setup documentation
ex:
export ANDROID_HOME=~/Library/Android/sdk
Windows:
set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk
macOS Mojave and earlier or bash users:
1 - Open your bash profile:
open .bash_profile
Add this to your bash_profile:
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.bash_profile
For macOS Catalina and zsh users:
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
On your Mac:
Open your .zshrc file:
open ~/.zshrc
If .zshrc file not exist, you need to create one using touch & open.
touch ~/.zshrc
Add this to your .zshrc file
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
Save and close
Compile your changes
source ~/.zshrc
Edit: Updated answer for macOS Catalina and zsh users.
Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
More details on zsh from Apple
So on your Mac:
1 - Open your .zshrc file:
open ~/.zshrc
2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)
touch ~/.zshrc
3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
4 - Save and close
5 - Compile your changes
source ~/.zshrc
& make sure to restart your terminal.
I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.
> export ANDROID_HOME=~/Android/Sdk
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
good luck
this was my solutions
operating system: Linux mint
sudo apt-get install android-tools-adb
This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.
This is related to path issues.
If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.
Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
Make sure to add the above line correctly else it will give you a weird error.
Save the changes and close the editor.
Finally, now compile your changes
source ~/.zshrc
I get this working in my case. I hope this helps you.
I solved this error with installing adb
On Linux
sudo apt-get install android-tools-adb
First I have setup the path in .bash_profile like this
export PATH="~/Library/Android/sdk/platform-tools":$PATH
export ANDROID_HOME="~/Library/Android/sdk/platform-tools"
But it does not resolve my problem.
For me by adding following npm script in package.json under script tag worked like charm on Mac.
"android-dev": "adb reverse tcp:8081 tcp:8081 && react-native run-android"
Then I am simply running npm run android-dev and it's all set. Make sure that in your app setting Live reload is enabled already, in this way I can worked on development server on my mobile and see the coding changes immediately in app.
I was on Linux and in my case the ANDROID_HOME env variable was already added to the .zshrc but the path was incorrect, correcting the path fixed it.
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator:$PATH
export PATH=$PATH:$ANDROID_HOME/tools:$PATH
export PATH=$PATH:$ANDROID_HOME/tools/bin:$PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools:$PATH
add these in the ~/.zshrc file and reload your terminal.
If none of the solution works. Try running
source ~/.bash_profile&&react-native run-android
Update this in the package.json file under scripts for android as
"android": "source ~/.bash_profile&&react-native run-android"
For MacOS version Catalina and above:
"android": "source ~/.zshrc&&react-native run-android"
This worked for me,
On Linux
sudo apt-get install android-tools-adb
For Mac only
If the accepted answer doesn't work for you then check if you have "adb" installed on your system. If not, install adb using homebrew.
touch ~/.zshrc
open ~/.zshrc
add
export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH
save
source ~/.zshrc
run android
In my situation, I'm on Pop OS(Ubuntu) and I have android-studio installed, so I just
ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

Couldn't find libtoolize, even though I have installed libtool in OSX Yosimite

I want to use Make install command and I have installed all requirements like yasm, nasm, curl, ant, rsync and the autotools: autoconf, automake, aclocal, pkgconfig, libtool. (Exactly, I want to compile Linphone Android NDK from Here : https://github.com/BelledonneCommunications/linphone-android. I have follow all steps from there)
I have try to install libtoolize using this command:
brew install libtoolize
But terminal always show :
Error: No available formula for libtoolize
If i try to make install, terminal will show :
Could not find libtoolize. Please install libtool.
Anybody can help ?
You should install the package libtool via
brew install libtool
This package contains the tool libtoolize as you can check via
brew list libtool
Note the warning
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
You may try again installing the tools you want to. If the come with a ./configure script, re-execute it to let it find glibtoolize. If this does not work, you may need to set the environment variable LIBTOOL to the version Homebrew installed:
export LIBTOOL=`which glibtool`
export LIBTOOLIZE=`which glibtoolize`
As a last resort, you may need to set a symbolic link from glibtoolize to libtoolize. You can do so via
ln -s `which glibtoolize` libtoolize
Then, add the directory with the link to the path by
export PATH=$(pwd):$PATH
Then, libtoolize should be found.
Maybe you should refer to this Linphone for android is not working/missing libraries. Autotools installation for mac as suggested a part of the step.
# Assume we want to install them below $HOME/local.
myprefix=$HOME/local
# Ensure the tools are accessible from PATH.
# It is advisable to set this also in ~/.profile, for development.
PATH=$myprefix/bin:$PATH
export PATH
# Do the following in a scratch directory.
wget http://ftp.gnu.org/gnu/m4/m4-1.4.14.tar.gz
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.64.tar.gz
wget http://ftp.gnu.org/gnu/automake/automake-1.11.1.tar.gz
wget http://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz
gzip -dc m4-1.4.14.tar.gz | tar xvf -
gzip -dc autoconf-2.64.tar.gz | tar xvf -
gzip -dc automake-1.11.1.tar.gz | tar xvf -
gzip -dc libtool-2.4.tar.gz | tar xvf -
cd m4-1.4.14
./configure -C --prefix=$myprefix && make && make install
cd ../autoconf-2.64
./configure -C --prefix=$myprefix && make && make install
cd ../automake-1.11.1
./configure -C --prefix=$myprefix && make && make install
cd ../libtool-2.4
./configure -C --prefix=$myprefix && make && make install

Android SDK path issue when using calabash-android

I'm getting a "Could not find an Android SDK please make sure it is installed" error when trying to run calabash-android commands. I've installed the Android SDK via brew. Here are the contents of my .bash_profile:
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.2
PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/build-tools
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
PATH=$PATH:/usr/local/apache-ant-1.9.4/bin
PATH=$PATH:/usr/local/share/npm/bin
JAVA_HOME=/usr/libexec/java_home
export PATH
Here's my $PATH:
echo $PATH
/Users/mchumak/.rvm/gems/ruby-2.1.1/bin:/Users/mchumak/.rvm/gems/ruby-2.1.1#global/bin:/Users/mchumak/.rvm/rubies/ruby-2.1.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/android-sdk/24.2/tools:/usr/local/Cellar/android-sdk/24.2/platform-tools:/usr/local/Cellar/android-sdk/24.2/build-tools:/Users/mchumak/.rvm/bin:/Users/mchumak/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Users/mchumak/.rvm/bin:/usr/local/apache-ant-1.9.4/bin:/usr/local/share/npm/bin
"which android" produces:
/usr/local/bin/android
The contents of that particular file are:
#!/bin/bash
TOOL="/usr/local/Cellar/android-sdk/24.2/tools/android"
exec "$TOOL" "$#"
I can run the Android SDK Manager from the command line just fine, and it shows the correct SDK path (/usr/local/Cellar/android-sdk/24.2).
I'm stumped. Any ideas why calabash-android can't find the SDK?
This will fix your issue,
echo "export PATH=$PATH:/Users/#username/Library/Android/sdk/platform-tools/sdk/platform-tools/" >> ~/.bash_profile
install android-platform-tools -> brew install android-platform-tools
- Also ensure yourself have admin rights
Looking at your $PATH output seems like android sdk path isnt loaded into PATH. Add below to your .bash_profile
PATH=$PATH:$ANDROID_HOME
calabash-android run /Users/marcg/Downloads/app-news.apk
I received that following error
Could not find any platform directory in '/Users/marcg/Library/Android/sdk/platforms'
I corrected this with the symlink below:
/Users/marcg/Library/Android/sdk/platforms
platforms$ ln -s ../platform-tools/ platform
I ran again and get an error that the android jar was missing from a standard directory of /Users/marcg/Library/Android/sdk/platforms
I then copied that android.jar to this platforms dir
Dir now looks like:
/Users/marcg/Library/Android/sdk/platforms
us164912:platforms marcg$ ls -l
total 49640
-rwxr-xr-x 1 marcg Users 25409822 Oct 5 09:26 android.jar
lrwxr-xr-x 1 marcg Users 18 Oct 5 09:14 platform -> ../platform-tools/
Still getting
Did not find 'android.jar' in any standard directory of '/Users/marcg/Library/Android/sdk/platforms'. Calabash will therefore take longer to load
I copied the android.jar to the platform-tools directory and remaining error went away.
Steps to correct:
Make a symlink in platforms that points to platform-tools
ln -s ../platform-tools/ platform
Copy the android.jar to the platform-tools dir
Would be better if the framework allowed you configure via file or additional env vars where to find each of these. My earlier attempt to set ANDROID_HOME to the platform-tools dir didn't work and why I did a symlink.

Permission Denied: Initializing repo for building Android source

Linux and programming noob here...
I'm following the instructions # http://source.android.com/source/downloading.html
I run into trouble when I run the following line:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
I get:
bash: /home/dev/bin/repo: Permission denied
And yes I've tried to sudo it.
Thank you! :)
==================================================================================
EDIT:
I downloaded the script manually in a browser, popped-it into the home/dev/bin/ directory, and I am still unable to progress. Here is what my terminal window is giving me:
dev#Android-Dev:~$ sudo chmod a+x ~/bin/repo
[sudo] password for dev:
dev#Android-Dev:~$ cd /home/dev/bin/
dev#Android-Dev:~/bin$ sudo mkdir wip
dev#Android-Dev:~/bin$ cd wip
dev#Android-Dev:~/bin/wip$ repo init -u **<This is where the URL goes>**
fatal: cannot make .repo directory: Permission denied
dev#Android-Dev:~/bin/wip$ sudo repo init -u **<This is where the URL goes>**
sudo: repo: command not found
dev#Android-Dev:~/bin/wip$ cd bin
bash: cd: bin: No such file or directory
dev#Android-Dev:~/bin/wip$ cd ..
dev#Android-Dev:~/bin$ sudo repo init -u **<This is where the URL goes>**
sudo: repo: command not found
I ran into the same problem. changing the ownership helped me. When I try to curl https..://myrepo...u...r...l../repo > ./repo into my /opt/android dir it gives me this error.
I do sudo chown -R shraddha /opt/android that works
In CYGWIN you can do below.
edit .bash_profile and uncomment these fields. (any text editor will do)
# Set PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
# PATH="${HOME}/bin:${PATH}"
# fi
Restart CYGWIN.
Under BASH, enter:
$ export PATH=$PATH:~/bin
Or add as follows to your .bashrc file:
$ echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
If you are using CSH / TCSH, enter:
$ echo 'set PATH = ($PATH ~/bin /scripts/admin)' >> ~/.cshrc
To display path settings, enter:
$ echo $PATH
Maybe you're behind a proxy? Try to download repo tool manually (just put this link into your browser). (I guess that maybe this resource can be prohibited for you). And then put it into this folder and assign permissions to it. I do not see any wrong steps in what you've described so far.
you can try this:
wget http://git-repo.googlecode.com/files/repo-1.14
After that,
you can see the repo-1.14, and you can mv it to anywhere or change the name,such as :
sudo mv repo-1.14 ~/bin/repo
The repo file is not executable. Run chmod a+x ~/bin/repo to turn it into an executable file and this should fix your problem.

Categories

Resources