Skip to content

Deepscorn/libgdx-gradle-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

That project is an enhanced gradle configuration for libgdx

Features

  1. Decoupled projects - when working on android project, you wount see gradle doing something with RoboVM which is used only for iOS. So better performance and stability
  2. Java 8 support (tested desktop & android) with lambdas

What this project is for

That project is not for HTML and Eclipse. It is primaraly used to write java 8 code in core and deploy for android & desktop. While iOS must work too (RoboVM has support for java 8) I update iOS project very rarely. If you want to do that, you can make a pull request.

Prerequisites

  1. JAVA_HOME set to Jdk 8 path

Known problems

You may need to disable "instant run" in IDE to make java 8 work (see https://developer.android.com/preview/j8-jack.html)

IDE's support

  1. Android Studio
  2. IDEA
  3. AIDE on mobile phone/tablet - use aide branch

Android Studio

Import gradle project in Android Studio

IDEA

Import in IDEA as gradle project:

check auto-import,

uncheck create separate module per source set,

use default gradle wrapper

AIDE

AIDE has limitations on building gradle projects at the time of writing. So gradle configuration was simplified - see aide branch. Some things we need to do by hand:

  1. Copy android/src/main/jniLibs from desktop to mobile device

  2. Build core project on desktop, then copy built core.jar to android/libs

Build app for android


First, uncomment unpackNatives() task found in android/build.gradle. You need to do that in regular gradle project setup in libgdx - it's not specific to this repo. Script is used to unpack jars and put .so in correct directories, so that they will be included in apk. Nothing more is needed to do, just click "run" in IDE or execute in terminal:

./gradlew :android:installRelease

or

./gradlew :android:installDebug

Build app for iOS


Libgdx regular gradle setup has bug which persists in this repo too. The workaround is simple. Assure that:

org.gradle.daemon=false

in gradle.properties (see robovm/robovm#867) or you may get UnsatisfiedLinkError: Native Library already loaded in another classloader

now you can build as normal:

./gradlew :ios:launchIOSDevice

or

./gradlew :ios:launchIPhoneSimulator

or

./gradlew :ios:launchIPadSimulator

Note, that running on simulator I sometimes get an error related to audio playing. It's a RoboVM bug: libgdx/libgdx#1485. Will appreciate solving that mystery for me. I'm new to iOS develop and I don't here any sound playing in simulator. I think, it's switched off but I don't see any reason to crash when audio not available. Check https://github.com/Deepscorn/NewLibGDXProjectTemplate/tree/duckhunttest if you want to reproduce.

AIDE story

AIDE is an IDE, running on regular android device. It has limitations, I tried to overcome. See below

  1. Constants not working.
buildscript { ext { gdxVersion=1.9.3 } }
dependencies {
  compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
}

So, have to write:

compile "com.badlogicgames.gdx:gdx-backend-android:1.9.3"
  1. Building core gradle project as regular java project in AIDE doesn't work. At the time of writing AIDE opens core as android project (probably it doesn't know that regular java project can use gradle build system) and fails to compile it. The suggestion is to build it on desktop and copy jar. To be able to write core code on mobile device you can write it in android project. Then just move it when you are back on desktop and build new jar. It's ugly, but it's working

Useful gradle commands

gradlew clean --no-daemon // Clean project, that one used by official setup script

Further reading

http://deepscorn.blogspot.ru/2016/07/building-and-running-android-studio.html

http://deepscorn.blogspot.ru/2015/05/speed-up-libgdx-gradle-build-in.html

http://deepscorn.blogspot.ru/2015/05/libgdx-kotlin-setup.html

About

libGDX project template with optimized performance in IDE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages