Nativescript - how to create a new AVD emulator on MacOS - nativescript

How can I create a new AVD emulator for Mac OS.
I don't have Android Studio installed - would prefer not to.
Docs talk about a program avdmanager -but I don't have it.
I think that gets installed with a certain Android sdk tools version - but I'm not getting the option to upgrade in my sdkmanager

+1 on comment of Liberbon
just change the x86 to x86_64 if you are using 64 bit OS.
In my case this solved my issue, I am using Mac OS v10.14.6

Install the dependencies for Android development.
Make sure that these initial steps are done before you create AVD emulator.
# Install Java 8 and Android SDK
brew tap caskroom/versions
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
brew cask install android-sdk
# Set environment variables
echo "export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)" >> ~/.bash_profile
echo "export ANDROID_HOME=/usr/local/share/android-sdk" >> ~/.bash_profile
source ~/.bash_profile
# Install all Android SDK packages
$ANDROID_HOME/tools/bin/sdkmanager "tools" "emulator" "platform-tools" "platforms;android-28" "build-tools;28.0.3" "extras;android;m2repository" "extras;google;m2repository"
Create Android Virtual Device via command line.
# Load image if it's missing (optional)
$ANDROID_HOME/tools/bin/sdkmanager "system-images;android-28;google_apis;x86_64"
# Create android emulator with avdmanager
$ANDROID_HOME/tools/bin/avdmanager create avd -n Emulator-Api28-Google -k "system-images;android-28;google_apis;x86_64"
References:
https://docs.nativescript.org/start/ns-setup-os-x
https://docs.nativescript.org/tooling/android-virtual-devices#creating-android-virtual-device-via-command-line-tool
UPD:
2020-05-21: Changed brew cask install java8 to brew cask install adoptopenjdk/openjdk/adoptopenjdk8.
2020-05-21: Changed x86 to x86_64. Thanks #Bon Tobiel Blancia for advice.

Related

Cordova doesn't see installed Android SDK

When I run cordova requirements my Mac tells me I don't have any android targets installed, yet Android Studio tells me I have.
I have set JAVA_HOME and ANDROID_HOME as below in .bash_profile:
export JAVA_HOME=/usr/libexec/java_home
export ANDROID_HOME=/Users/darrensweeney/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/emulator
Yet when I run cordova requirements I see the following:
Am I missing a step?
I have also tried removing and re-adding the Android platform within Cordova, no difference.
Update:
Android Studio was throwing an error Please select Android SDK which I fixed by syncing with Gradle.
Now cordova requirements shows the following:
How can I make it see that android-30 is installed?
After a couple of hours digging, there's a better way to do this:
Install the android-sdk library:
brew install --cask android-sdk
This then allows you to use the sdkmanager to add any platform:
sdkmanager "platforms;android-30"

How to switch between multiple Command Line Tools installations in Mac OS X (without installing XCode)

Is it possible to install and switch between multiple version of Command Line Tools in Mac OS X? I was wondering if it's possible use xcode-select but the Command Line Tools installer doesn't have an option to choose the installation destination. I tried to create multiple installations by manually renaming Library/Developer/CommandLineTools and then passing it to xcode-select. The command succeeds but when I try to access gcc I get:
gcc: error: unable to find Xcode installation from active developer path "/Library/Developer/CommandLineTools_9.0.0", use xcode-select to change
It seems this is possible when installing the whole XCode but I have no need for XCode and prefer not to install it. All I need is the command line tools.
I tried to do the same and after some experiments found the next solution. Yes, it is possible but you need to copy/rename the whole /Library/Developer folder. For example:
1) first, I just show my macOS version:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G65
2) download and install Command Line Tools for Xcode, e.g. 10b5 version
3) create folders to store different versions of tools:
$ mkdir ~/Project/tools
$ mkdir ~/Projects/tools/Developer10b5
$ mkdir ~/Projects/tools/Developer9.4.1
4) copy the whole Developer folder:
$ cp -R /Library/Developer/ ~/Project/tools/Developer10b5/
5) then, download and install Command Line Tools for Xcode, e.g. 9.4.1 version
6) copy the whole Developer folder:
$ cp -R /Library/Developer/ ~/Project/tools/Developer9.4.1/
7) switch to 9.4.1 version of tools and check the clang version:
$ sudo xcode-select -s ~/Project/tools/Developer9.4.1/
$ clang --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/<username>/Projects/tools/Developer9.4.1/CommandLineTools/usr/bin
8) switch to 10b5 version of tools and check the clang version:
$ clang --version
Apple LLVM version 10.0.0 (clang-1000.10.40.1)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Users/<username>/Projects/tools/Developer10b5/CommandLineTools/usr/bin
For those who have a problem like as #PaulMasri-Stone, I found that after removing a previously installed Xcode (installing multiple versions of Xcode was not an option on my computer because of space), the method above also gave me the 'invalid developer directory' error.
I overcame this problem by typing sudo xcode-select -r to reset to the default command-line tools (and reset whatever other underlying state that the system uses to track the SDK location -- and lack of Xcode), followed by sudo xcode-select -s /Library/Developer/CommandLineTools10.13_Xcode9.4.1. Note that sudo xcode-select -s /Library/Developer would not work for me, just like the problem that #PaulMasri-Stone had.
Otherwise, you will want to follow the instructions that #Ilirium specified, but you only need to copy/rename the CommandLineTools directory.
These instructions worked for me. #PaulMasri-Stone - Instead of pointing xcode to the root directory, I had to point it to the CommandLineTools directory like so:
sudo xcode-select -s ~/projects/tools/llvm1131/CommandLineTools/

How do i install xcode on my ubuntu machine?

I have Lenovo Ideapad310 laptop with Ubuntu OS. But for iOS development I want to install Xcode in my machine, so how can i install Xcode in my machine?
please anyone help me??
First: You can't install Xcode on Ubuntu it's restricted only for Mac OS.
Second: I assume you want Swift, which you can install it over terminal using this command
sudo apt-get install clang
If you installed the Swift toolchain on Linux to a directory other than the system root, you will need to run the following command, using the actual path of your Swift installation:
export PATH=/path/to/Swift/usr/bin:"${PATH}"
You can verify that you are running the expected version of Swift by entering the swift command and passing the --version flag:
swift --version
for IDE you might use Visual Studio Code and install Swift plugin.
Good Luck

First Setting up Phonegap on MacBook

I've bought my first ever MacBook having never used a Mac before and need to know how to set up pretty much the same tools or learn whatever the Mac version of these tools are, heres a guide I wrote for getting started with Phonegap on Windows, if I follow it as close as I can, will everything work?
• Download/ Install Node.JS
• Download/ Install GIT for windows
• Download/ Install Phonegap by opening NODE.JS command line and
typing: npm install -g phonegap
• Download/ Install Apache 2.4
• Download/ Install Apache Ant
• Add Variable name: ANT_HOME with filepath to User/ System variables
(e.g. C:\apache-ant-1.9.4 )
• Add %ANT_HOME%/bin to PATH under user variables
• Download/ Install JRE ( select applicable version number (if in
doubt then most recent))
• Download/ Install JDK (Select applicable version number (if in doubt
then most recent))
• Add Variable name: JAVA_HOME with filepath to User/ System variables
(e.g. C:\Program Files\Java\jdk1.7.0_60 )
• Add %JAVA_HOME%/bin to PATH under user variables
• Download / Extract Android SDK ( select "download for other
platforms" and select version to avoid downloading their bundle)
• Add Android SDK Tools folder eg: C:\android-sdk-windows\tools to the
PATH variable
• Add Android SDK Platform tools eg:
C:\android-sdk-windows\platform-tools to the PATH variable
Thankyou in advance for your help!
Lewis
The mac is build on a unix platform.
This means it comes with a lot of tools that are Linux like.
To install application on the mac you can use brew ( http://www.brew.sh ). Brew is a package management system similar to the ones from linux world (yum for RedHat or apt-get for Ubuntu).
To install brew run this command in the Terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
After you have brew installed on your machine, you can add your packages with:
brew install [packagename]
Your installation flow would look like this:
brew install node
brew install git
npm install -g phonegap
For apache and ant check the existing answers on stackoverflow.
To add environment variable on mac use the Terminal and edit your “.profile” or “.bash_profile”. There are detailed answear on stackoverflow regarding this subject.
Java will need to be installed from the Oracle website (download the .dmg file and execute it)
brew install android-sdk

Remove Qt libraries on Mac

I want to remove the installed Qt 4.8 libraries and install Qt 4.6 libraries on my mac.
But when I try to install them I get:
"Qt libraries cannot be installed on this disk. A newer version of
this software already exists on this disk"
I removed the /usr/local/Qt4.8.x folder from the disk but the message is still here.
How can I remove the old libraries?
You shouldn't manually delete a folder unless there is no other option. You should try running the uninstall script first:
sudo python /Developer/Tools/uninstall-qt.py
The path to this script will be different if you are running the latest Xcode app bundle and not the default Snow Leopard/Lion Xcode.
I installed qt via homebrew. To remove I simply wrote the following in the terminal: brew uninstall qt#4

Resources