Location>code7788 >text

Gluon compiles JavaFx -> android apk

Popularity:830 ℃/2024-09-01 17:43:50

Gluon Compiling JavaFx -> android apk

This article is about building a Gluon build android-apk environment on a linux server.

This article follows directly from the official website with one-time success

Virtual Machine Versions

  • centos8 Architecture: x86-64

Start installing the relevant pre-installation tools

  • gcc version 6 or higher
  • ld version 2.26 or higher
sudo yum update
sudo yum install gcc ld -y
sudo yum install pkgconfig gtk3-devel libXtst-devel -y

If you encounter connection timeout problems, update the yum source, I switched to Aliyun yum source, centos8 system referencethis article

Here's what I've distilled

The # command backs up the previous repo file
sudo rename '.repo' '.' /etc//*.repo
# Run the following command to download the latest repo file
# Note that we are not an ECS instance of AliCloud.
# You need to replace the source address in all the commands that follow with
sudo wget /repo/Centos-vault-8.5. -O /etc//Centos-vault-8.5.
sudo wget /repo/ -O /etc//
# Replace the links in the repo file
sudo sed -i 's/http:\/\//url_tmp/g' /etc//Centos-vault-8.5. && sudo sed -i 's/http:\///http:\///g' /etc//Centos-vault-8.5. && sudo sed -i 's/http:\//http:\\/g' /etc//Centos-vault-8.5. && # Replace links in the repo file with the following. amp; sudo sed -i 's/url_tmp/http:\/\//g' /etc//Centos-vault-8.5.
sudo sed -i 's/http:\////http:\///g' /etc//
# Re-create the cache
sudo yum clean all && yum makecache

Configuring Environment Variables

vi ~/.bashrc # Edit to user environment variable
export HISTSIZE=10000 # Set the maximum number of entries to 1000
export HISTFILESIZE=20000 # Set the number of history entries saved for the last session to 2000
export HISTCONTROL=ignoreboth # Ignore duplicate command arguments and commands that have not yet been executed
export PATH=$PATH:~/bin
source ~/.bashrc # Reload the user environment variable in the

Environment Tool Configuration

Graalvm Environment Build

First, go to wsl and find a suitable directory.

# Pull the VMs used for the build
mkdir ~/software ~/module
cd ~/software
wget /gluonhq/graal/releases/download/gluon-22.1.0.1-Final/graalvm-svm-java17-linux-gluon-22.1.0.
cd ~/module
tar -zxvf . /software/graalvm-svm-java17-linux-gluon-22.1.0.

graalvm is a special java virtual machine environment that primarily uses theAOTMold packaged to build a virtual machine version for multiple platforms, which can be used directly as a regular jdk

Configuring the maven environment
cd ~/software
wget /maven/maven-3/3.9.9/binaries/apache-maven-3.9.
cd ~/module
tar -zxvf ../software/apache-maven-3.9.

Modify the maven settings file

vi ~/module/apache-maven-3.9.9-bin/conf/
<!-- Adding Mirrors -->
<mirror>
    <id>alimaven</id>
    <name>aliyun maven</name>
    <url>/nexus/content/groups/public/</url>
    <mirrorOf>central</mirrorOf>
</mirror>
<mirror>
    <id>repo2</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name for this Mirror.</name>
    <url>/maven2/</url>
</mirror>

Configure new environment variables (my maven, graalvm into ~/module directory)
vi ~/.bashrc # Edit to user environment variable
export GRAALVM_HOME=~/module/graalvm-svm-java17-linux-gluon-22.1.0.1-Final
## JAVA_HOME
export JAVA_HOME=$GRAALVM_HOME
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/:$JAVA_HOME/lib/

export MVN_HOME=~/module/apache-maven-3.9.9
export PATH=$PATH:$MVN_HOME/bin
source ~/.bashrc # Reload the user environment variable in the

Here the basic environment has been configured, as for the andriod sdk here do not need to explicitly configure, because gluonfx this tool will automatically download the relevant dependencies in the process of packaging, the andriodSdk non-essential.
Specific reference can be made toGluon Official Website Documentation

Compile the official website sample project

Prepare a script that specializes in executing gluonfx to compile Android

mkdir ~/bin
vi ~/bin/gluon_build_android
chmod +x ~/bin/gluon_build_android
source ~/.bashrc # Reload the user environment variables in the

~/bin/gluon_build_androidof the following

mvn clean package -DskipTests=true
mvn -P android gluonfx:build gluonfx:package -DskipTests=true

Pull up the official websiteSample Project HelloFx

mkdir ~/module/git-repos
cd ~/module/git-repos
git clone /gluonhq/
cd gluon-samples/HelloFx
gluon_build_android # Execute the previously defined scripts