Mac Angular project Cordova compiled Android package

Keywords: Android angular Mac cordova

Basic steps

1. The first is the official website download Java JDK8 , Java 8, Mac  , Download to register with oracle, recommended Shared account

After installation, configure the environment variables and open the command terminal

#Open profile
open .bash_profile
#If you can't open it, create this file
touch .bash_profile
#Remember to run the saved file after modification
source .bash_profile

This will open a notepad and add the following contents to it. The version jdk1.8.0 in it_ 301 directory, according to your own installation, you can go to the installation location and enter "Command + Shift +." on Mac to display the hidden folder

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH:.
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.

  

After modification, run the above save file command, and then detect "java -version". ok !

2. Because you still need some Android environment and SDK, it's troublesome to install it yourself, so you choose to directly install an Android Studio development tool, which will bring your own Android environment.

After loading and configuring the Android environment variable, it is consistent with the java environment variable, and open the same bash_ Add the following content to the profile

# Android ADB configuration
export ANDROID_HOME=/Users/Your own account directory/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=$PATH:$ANDROID_HOME/build-tools/31.0.0

Remember to change your account directory and the 31.0.0 directory. Change it according to your installation. Finally, run the Save command

input   Did the adb test install successfully

3. Go to your Angular cordova project to see if it can be packaged and compiled

#Global install cordova
sudo npm install -g cordova
# Add Android platform environment
cordova platform add android

  cd to project terminal

# function
cordova run android
# pack
sudo ionic cordova build android

 

Problem summary

First question

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\tanmay\AppData\Local\Android\sdk (DEPRECATED)
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
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android --release exited with exit code 1.

Solution: the main reason is the lack of gradle environment, so you need to install gradle manually. I installed homebrew and then installed it with the command. If there is an environment, I can directly run the second installation command

# Install homebrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# Install grade through homebrew
brew install gradle

 

Second question

Solution: the problem is that you have these environments, but you don't agree with some of his licenses protocols. Enter the command

#Switch to Android installation directory
cd /Users/Your username/Library/Android/sdk
cd tools
cd bin
# Execute certification, all the way y down
./sdkmanager --licenses

Finally, it's all done. Try again

  

  The third question

Solution: (the solution is inappropriate and is being updated continuously) go to the platforms/android/project.properties file in the project directory  

Find the wrong "com. Android. Support: support XXX" in the figure and comment them out, as I corresponding

 

 

Posted by cruzbullit on Sun, 26 Sep 2021 19:53:55 -0700