sh Ionic Framework的Ubuntu开发人员脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Ionic Framework的Ubuntu开发人员脚本相关的知识,希望对你有一定的参考价值。

###Install Android, Cordova, and Ionic Framework in Ubuntu

To install everything using the shell script I provided, download it and do the following

```
chmod 775 ubuntu_ionic_installer.sh
sudo ./ubuntu_ionic_installer.sh
```

The installation script will download and configure the following:

* Java JDK
* Apache Ant
* Android SDK
* NodeJS / NPM
* Apache Cordova
* Ionic Framework

You can find most of these items installed to your operating system’s `/opt` directory. Once setup has completed, you will need to restart your Ubuntu session, by logging out or restarting your machine. When you sign back in you will need to download the various Android targets that could not be installed via a command line.

##Error: ANDROID_HOME is not set and "android" command not in your PATH

*Add below lines to  ~/.zshrc or ~/.bashrc*

```
export PATH=$PATH:/opt/android-sdk/tools
export PATH=$PATH:/opt/android-sdk/platform-tools
export PATH=$PATH:/opt/node/bin
export JAVA_HOME=/usr/lib/jvm/default-java
export ANDROID_HOME=/opt/android-sdk

source ~/.zshrc
OR
source ~/.bashrc
```

##Error: Please install Android target "android-19".

Hint: Run `android` from your command-line to open the SDK manager.

1) Went into the SDK Manager (typing android into the terminal, assuming it's in your file path)

2) Selected box next to Android 4.4.2 (API 19)

3) Clicked button Install 8 packages

4) Ran original command (in this example `cordova platform add android`, although it could be `ionic platform add android`, depending on what you're working with)

Then check target listed using command.
`android list target`

##Start building with Ionic!
```
ionic start myApp tabs
ionic start myApp blank
ionic start myApp sidemenu

cd myApp
ionic platform add android
ionic build android
ionic emulate android
```

#!/bin/bash
# Ubuntu Developer Script For Ionic Framework
# Created by Nic Raboy
# http://www.nraboy.com
#
#
# Downloads and configures the following:
#
#   Java JDK
#   Apache Ant
#   Android
#   NPM
#   Apache Cordova
#   Ionic Framework
 
HOME_PATH=$(cd ~/ && pwd)
INSTALL_PATH=/opt
ANDROID_SDK_PATH=/opt/android-sdk
NODE_PATH=/opt/node
 
# x86_64 or i686
LINUX_ARCH="$(lscpu | grep 'Architecture' | awk -F\: '{ print $2 }' | tr -d ' ')"
 
# Latest Android Linux SDK for x64 and x86 as of 10-19-2014
ANDROID_SDK_X64="http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz"
ANDROID_SDK_X86="http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz"
 
# Latest NodeJS for x64 and x86 as of 10-19-2014
NODE_X64="http://nodejs.org/dist/v0.10.32/node-v0.10.32-linux-x64.tar.gz"
NODE_X86="http://nodejs.org/dist/v0.10.32/node-v0.10.32-linux-x86.tar.gz"
 
# Update all Ubuntu software repository lists
apt-get update
 
cd ~/Desktop
 
if [ "$LINUX_ARCH" == "x86_64" ]; then
 
    wget "$NODE_X64" -O "nodejs.tgz"
    wget "$ANDROID_SDK_X64" -O "android-sdk.tgz"
 
    tar zxf "nodejs.tgz" -C "$INSTALL_PATH"
    tar zxf "android-sdk.tgz" -C "$INSTALL_PATH"
 
    cd "$INSTALL_PATH" && mv "android-sdk-linux" "android-sdk"
    cd "$INSTALL_PATH" && mv "node-v0.10.32-linux-x64" "node"
 
    # Android SDK requires some x86 architecture libraries even on x64 system
    apt-get install -qq -y libc6:i386 libgcc1:i386 libstdc++6:i386 libz1:i386
 
else
 
    wget "$NODE_X86" -O "nodejs.tgz"
    wget "$ANDROID_SDK_X86" -O "android-sdk.tgz"
 
    tar zxf "nodejs.tgz" -C "$INSTALL_PATH"
    tar zxf "android-sdk.tgz" -C "$INSTALL_PATH"
 
    cd "$INSTALL_PATH" && mv "android-sdk-linux" "android-sdk"
    cd "$INSTALL_PATH" && mv "node-v0.10.32-linux-x86" "node"
 
fi
 
cd "$INSTALL_PATH" && chown root:root "android-sdk" -R
cd "$INSTALL_PATH" && chmod 777 "android-sdk" -R
 
cd ~/
 
# Add Android and NPM paths to the profile to preserve settings on boot
echo "export PATH=\$PATH:$ANDROID_SDK_PATH/tools" >> ".profile"
echo "export PATH=\$PATH:$ANDROID_SDK_PATH/platform-tools" >> ".profile"
echo "export PATH=\$PATH:$NODE_PATH/bin" >> ".profile"
 
# Add Android and NPM paths to the temporary user path to complete installation
export PATH=$PATH:$ANDROID_SDK_PATH/tools
export PATH=$PATH:$ANDROID_SDK_PATH/platform-tools
export PATH=$PATH:$NODE_PATH/bin
 
# Install JDK and Apache Ant
apt-get -qq -y install default-jdk ant
 
# Set JAVA_HOME based on the default OpenJDK installed
export JAVA_HOME="$(find /usr -type l -name 'default-java')"
if [ "$JAVA_HOME" != "" ]; then
    echo "export JAVA_HOME=$JAVA_HOME" >> ".profile"
fi
 
# Install Apache Cordova and Ionic Framework
npm install -g cordova
npm install -g ionic
 
cd "$INSTALL_PATH" && chmod 777 "node" -R
 
# Clean up any files that were downloaded from the internet
cd ~/Desktop && rm "android-sdk.tgz"
cd ~/Desktop && rm "nodejs.tgz"
 
echo "----------------------------------"
echo "Restart your Ubuntu session for installation to complete..."

以上是关于sh Ionic Framework的Ubuntu开发人员脚本的主要内容,如果未能解决你的问题,请参考以下文章

二:Ionic Framework支持Android开发

Ionic Framework - 上传到 Ionic View 应用程序,没有获取最新的 javascript 文件,可能缓存仍然存在?

十分钟使用ionic Framework开发一个跨平台移动应用

使用ionic framework创建一个简单的APP

Ionic Framework 应用程序适用于“离子服务”,但不适用于 Ionic View 应用程序

选择默认选项不适用于 Ionic Framework