A Demo showing how to create a cross platform game on Android & Desktop using JMonkeyEngine.
Note : The project uses gradle 6.7.1, to support java-8 on android studio 4.2.0, you can upgrade to gradle-7.2.1 and use AGP-7 as you like.
-
Game module
:game
: holdsbuild.gradle
dependencies for the game code & should hold your code. -
Desktop module
:desktop
: holdsbuild.gradle
for desktop dependencies & implements the:game
module, this module can hold the desktop gui. -
Android module
:app
: holdsbuild.gradle
for the android dependencies & implements the:game
module, this module can hold android dependent gui.
-
Gradle.
-
A single assets res folder (gradle resource folder).
-
Android Support via
:app
module. -
Desktop Support via
:desktop
module. -
Jar building task & app assembly.
./gradlew run
Install the app on a connected device via adb.
┌─[✗]─[twisted@parrot]─[~/AndroidStudioProjects/CrossPlatformModule]
└──╼ $./gradlew :app:installDebug
> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Redmi Note 6 Pro - 10' for app:debug
Installed on 1 device.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 4s
33 actionable tasks: 1 executed, 32 up-to-date
┌─[twisted@parrot]─[~/AndroidStudioProjects/CrossPlatformModule]
└──╼ $./gradlew :desktop:copyJars
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1s
5 actionable tasks: 5 up-to-date
┌─[twisted@parrot]─[~/AndroidStudioProjects/CrossPlatformModule]
└──╼ $./gradlew :desktop:releaseJar
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 1s
6 actionable tasks: 6 up-to-date
./gradlew :app:assemble
-
Through Android Studio, you can code for both the desktop & the android at the same time.
-
Command Line tools using git & gradlew commands.
=> Thanks Ali_RS for the suggestion of separating game module from desktop and android ones.
=> Thanks wizzardo for fixing creating jar from desktop issue.
=> Android studio-AGP-Gradle release notes : https://developer.android.com/studio/releases/gradle-plugin
=> gradlew for android: https://developer.android.com/studio/build/building-cmdline
=> Gradle DSL : https://docs.gradle.org/current/dsl/index.html
=> Gradle for java : https://docs.gradle.org/current/userguide/multi_project_builds.html
=> Gradle/Groovy Udacity course by google : https://github.com/udacity/ud867/blob/master/1.11-Exercise-ConfigureFileSystemTasks/solution.gradle
=> See JMonkeyEngine Android Examples : https://github.com/Scrappers-glitch/jme3-Simple-Examples
https://github.com/Scrappers-glitch/DBTraining
https://github.com/Scrappers-glitch/Superior-Extended-Engine/tree/master/demoApp
=> See JMonkeyEngine Desktop Example : https://github.com/Scrappers-glitch/basic-gradle-template
=> See JMonkeyEngine RPI armhf Desktop Example : https://github.com/Scrappers-glitch/JmeCarPhysicsTestRPI