CentOS7にcordova環境構築(GUI無し）

CentOS7にcordova (android アプリコンパイル環境含む）の構築手順

android studioは導入せず、android sdkのみ入れてみました。
GUI環境無でapkファイルの生成までできます。


```sh
sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash -
sudo yum install nodejs
sudo npm install -g cordova
mkdir cordova
cd cordova/
cordova create myapp
cd myapp/
# cordova platform add ios
cordova platform add android
cordova requirements
```

```console
$ cordova requirements

Requirements check results for android:
Java JDK: not installed
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Android SDK: not installed
Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
Android target: not installed
android: Command failed with exit code ENOENT
Gradle: not installed
Could not find gradle wrapper within Android SDK. Could not find Android SDK directory.
Might need to install Android SDK or set up 'ANDROID_HOME' env variable.
Some of requirements check failed
```

https://www.remix.asia/blog/remix/2018/06/androidlinuxcentos7_64bit.html

```sh
sudo yum install java-1.8.0-openjdk-devel
sudo yum -y install unzip
curl -o sdk-tools-linux-4333796.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip
sudo mkdir /opt/android-sdk
sudo mv tools /opt/android-sdk/.
sudo chown -Rf root:wheel /opt/android-sdk
sudo chmod +x /opt/android-sdk/tools/bin/*
#sudo chmod -Rf g+xw /opt/android-sdk
export ANDROID_HOME=/opt/android-sdk
```

```console
$ cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
avdmanager: Command failed with exit code EACCES
Gradle: not installed
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
Some of requirements check failed
```

https://linuxize.com/post/how-to-install-gradle-on-centos-7/
gradleのインストール

```console
$ cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
Please install Android target / API level: "android-28".

Hint: Open the SDK manager by running: /opt/android-sdk/tools/android
You will require:
1. "SDK Platform" for API level android-28
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
Gradle: installed /opt/gradle/gradle-5.0/bin/gradle
Some of requirements check failed

```

```sh
curl -o gradle-5.0-bin.zip https://services.gradle.org/distributions/gradle-5.0-bin.zip
sudo unzip -d /opt/gradle gradle-5.0-bin.zip
export GRADLE_HOME=/opt/gradle/gradle-5.0
export PATH=${GRADLE_HOME}/bin:${PATH}
vi ~/.bash_profile
sudo /opt/android-sdk/tools/bin/sdkmanager "platforms;android-28"
sudo /opt/android-sdk/tools/bin/sdkmanager "platform-tools"
sudo /opt/android-sdk/tools/bin/sdkmanager "build-tools;29.0.2"
```

```console
$ cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-28,android-22
Gradle: installed /opt/gradle/gradle-5.0/bin/gradle
```
要件をクリヤーした

```
cordova build 
```

参考
https://tecadmin.net/install-latest-nodejs-and-npm-on-centos/
https://tecadmin.net/install-cordova-on-centos/

android apkコマンドラインでのビルド方法
https://www.remix.asia/blog/remix/2018/06/androidlinuxcentos7_64bit.html