Skip to content

Commit

Permalink
mgsx-dev#64 revisions: working demo for desktop, html, and Android
Browse files Browse the repository at this point in the history
Android demo now works without conflict with HTML, desktop demos.

Android Gradle Plugin / Gradle versions cannot exceed the following without unresolved errors.
Android Gradle Plugin Version: 7.4.2
Gradle Version: 7.5.1
  • Loading branch information
shpowley committed Apr 27, 2023
1 parent 88db91f commit 56cb3ec
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 314 deletions.
57 changes: 29 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
buildscript {
repositories {
gradlePluginPortal()
google()
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
}
repositories {
gradlePluginPortal()
google()
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath "org.wisepersist:gwt-gradle-plugin:$gwtPluginVersion"
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

allprojects {
group = 'com.github.mgsx-dev.gdx-gltf'
version = '2.1.0'
group = 'com.github.mgsx-dev.gdx-gltf'
version = '2.1.0'

ext {
gdxVersion = '1.11.0'
junitVersion = '4.13.2'
}
ext {
gdxVersion = '1.11.0'
junitVersion = '4.13.2'
}

repositories {
gradlePluginPortal()
google()
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://jitpack.io" }
}
repositories {
gradlePluginPortal()
google()
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://jitpack.io" }
}

apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: "idea"
}

eclipse.project.name = "gltf-root"
eclipse.project.name = "gltf-root"
1 change: 0 additions & 1 deletion demo/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
android:name="net.mgsx.gltf.demo.AndroidLauncher"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
210 changes: 121 additions & 89 deletions demo/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,124 +3,156 @@ apply plugin: "com.android.application"
configurations { natives }

dependencies {
implementation project(":demo:core")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"

implementation project(":demo:core")
implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
}

android {
compileSdkVersion 33
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

androidTest.setRoot('tests')
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
namespace "net.mgsx.gltf.demo"
compileSdkVersion 33
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
defaultConfig {
applicationId "net.mgsx.gltf.demo"
minSdkVersion 24
targetSdkVersion 33
versionCode 4
versionName "0.0.4"

androidTest.setRoot('tests')
}
packagingOptions {
resources {
excludes += ['META-INF/robovm/ios/robovm.xml']
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
defaultConfig {
applicationId "net.mgsx.gltf.demo"
minSdkVersion 24
targetSdkVersion 33
versionCode 4
versionName "0.0.4"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}


// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
doFirst {
file("libs/armeabi/").mkdirs()
file("libs/armeabi-v7a/").mkdirs()
file("libs/arm64-v8a/").mkdirs()
file("libs/x86_64/").mkdirs()
file("libs/x86/").mkdirs()

configurations.natives.copy().files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
doFirst {
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.copy().files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
}

tasks.whenTaskAdded { packageTask ->
if (packageTask.name.contains("package")) {
packageTask.dependsOn "copyAndroidNatives"
}
if (packageTask.name.contains("package")) {
packageTask.dependsOn "copyAndroidNatives"
}
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}

def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/com.mygdx.game.AndroidLauncher'
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/com.mygdx.game.AndroidLauncher'
}

// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}

jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}

classpath {
plusConfigurations += [project.configurations.natives]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}

project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}

// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");

iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value:"true")
}
}
}
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.natives]]]

iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
}
}
}
}
}
}
}
16 changes: 8 additions & 8 deletions demo/android/src/net/mgsx/gltf/demo/AndroidLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import android.os.Bundle;

public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GLTFDemo.AUTOLOAD_ENTRY = "BoomBox";
GLTFDemo.AUTOLOAD_VARIANT = "glTF";
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new GLTFDemo("models"), config);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GLTFDemo.AUTOLOAD_ENTRY = "BoomBox";
GLTFDemo.AUTOLOAD_VARIANT = "glTF";
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new GLTFDemo("models"), config);
}
}
21 changes: 13 additions & 8 deletions demo/core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
apply plugin: "java"

dependencies {
implementation project(":gltf")
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
testImplementation "junit:junit:$junitVersion"
testImplementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation project(":gltf")
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"

testImplementation "junit:junit:$junitVersion"
testImplementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
testImplementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["src"]
sourceSets.test.java.srcDirs = [ "test/" ]

sourceSets.test.java.srcDirs = ["test/"]

eclipse.project.name = appName + "-core"
Loading

0 comments on commit 56cb3ec

Please sign in to comment.