Minie for Androids

After struggling with Travis, Gradle, and the Android SDK/NDK for a couple days, I’m on the verge of finally adding Android support to Minie. However, since I’ve never built an Android app with JMonkeyEngine, I’ll need help testing this feature.

Would someone experienced in making Android applications be willing to run some simple tests for me?

7 Likes

I’m at work right now, but when I get home in 3 weeks I can help. (If they let us go home in 3 weeks, I just hope they do not quarantine us up here…)

1 Like

@tlf30 Thank you for volunteering. I imagine a quarantine in the Arctic would be mighty inconvenient!

Btw, is anyone available to test in the coming week? I’d hoped to include Android support in version 1.6, but if no one’s eager to try it, it can wait until 1.7 …

I don’t have any physical devices but I can do some tests on an emulator if that’s ok.

1 Like

Hi @sgold,
I can help. Please send me the files.

1 Like

It should be easy to do with android Gradle plugin. Here is how I do it on Linux.

1- Download Android SDK command line tools from Download Android Studio & App Tools - Android Developers (it’s 77 MB)

If you open the link above in the browser you can find available zip files under the “Command Line Tools only” part. Unzip it somewhere. After unzip you should see a folder named “tools”. Create a new folder somewhere on your disk and name it “android-sdk” and move the “tools” directory into it.

2- Clone this JME android Gradle template

Open local.properties and set the SDK path to the “android-sdk” directory you created in step 1.
In my case it looks like this:
sdk.dir=/home/ali/opt/android-sdk

3- Update build.gradle in root project to be like this:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
        google()
        gradlePluginPortal()
        maven { url  "http://palantir.bintray.com/releases" }
    }
    
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.palantir.baseline:gradle-baseline-java:0.54.0'
        classpath 'gradle.plugin.org.inferred:gradle-processors:2.1.0'
    }
}

apply plugin: 'com.android.application'

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
        google() 
	    maven { url "https://jitpack.io" }
    }
    
    ext {
        jmerepo='org.jmonkeyengine'
        jmeversion='3.3.0-beta1' //3.3.0-alpha1
    }
}

android {
    compileSdkVersion 23
    // To suppress this warning, remove "buildToolsVersion" from your build.gradle file, 
    // as each version of the Android Gradle Plugin now has a default version of the build tools.
    //buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId 'com.mycompany.mygame'
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1"
    }
    
    lintOptions {
        abortOnError false
    }
    
    //Uncomment to sign release APK
    /*signingConfigs {
        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }*/
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            //Uncomment to sign release APK
            //signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile (project(":game")) {
        exclude module: "jme3-lwjgl"
        exclude module: "jme3-desktop"
    }
    
    compile jmerepo + ':jme3-android:' + jmeversion
    compile jmerepo + ':jme3-android-native:' + jmeversion

    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
}

task copyAssets {
    delete 'src/main/assets'
    copy {
        from 'game/src/main/resources/_assets'
        into 'src/main/assets'
    }
}

//task wrapper(type: Wrapper) {
//}

clean.dependsOn copyAssets

and set gradle wrapper to gradle-5.4.1.

Now you can buid app. After build success you can find generated apk under the build/outputs/apk/debug/ directory of your project.

Hope this helps.

3 Likes

Emulator is fine.

Everything is in the public repo. Here is how to build Minie for JME 3.3 for testing:

    git clone https://github.com/stephengold/Minie.git
    cd Minie
    git checkout -b latest 282df4b1
    ./gradlew build

After a successful build, Maven artifacts will be found in MinieLibrary/build/libs .

Any app that uses jme3-bullet and jme3-bullet-native-android should make a suitable test. Remove jme3-bullet and jm3-bullet-native-android, add the Minie-1.5.0 you built. (Not the one at JCenter!)

The supported Android ABIs are: armeabi-v7a, arm64-v8a, x86, and x86_64.

Things to look for:

  1. Any unusual diagnostic messages while building Minie, building the app, or installing the app?
  2. Is the native library loaded successfully during the JmeAndroidSystem initialization? Exceptions are ignored, so you may want to set a debugger breakpoint to be sure.
  3. Is initJavaClasses() invoked the first time a PhysicsSpace or CollisionShape is created? If it is, there should be a message to standard output, saying Libbulletjme v5.5.3 initializing, but I don’t know what happens to standard output on an Android.
  4. Does game physics work as expected?
    • physics debug visualization, if any
    • gravity
    • collision detection
    • contact forces
  5. Any unusual diagnostic messages while running the app?

When you report back, please let me know what type of device you tested on, whether it was physical or emulated, and which ABI it used.

@Ali-RS: Thanks for the pointers. You assume I’d know what to do with the APK once I’d built it. I’ll try and see how far I get.

1 Like

How do I do that? I tried the following method:

sgold:~/Git/ext/JMEAndroidTemplate$ ./gradlew wrapper --gradle-version=5.4.1
bash: ./gradlew: Permission denied
sgold:~/Git/ext/JMEAndroidTemplate$ chmod +x gradlew
sgold:~/Git/ext/JMEAndroidTemplate$ ./gradlew wrapper --gradle-version=5.4.1
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
sgold:~/Git/ext/JMEAndroidTemplate$

I copied JME’s “gradle” directory from

into my project and updated gradle-wrapper.properties to use gradle-5.4.1

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

and configured IDE to use the wrapper.

1 Like

What is your default gradle version installed on your OS?
If it is >= 5.4.1 then I guess you should be fine to use it and you wont need to use wrapper.

1 Like

I guess this is because gradle-wrapper.jar is missing.

1 Like

I will jump on this now.
Let me setup some easy use cases.

1 Like

I’ve submitted a pull request for the Gradle wrapper issues.

1 Like

My system’s default Gradle version is 4.4.1, but I use 6.3 for most of my projects.

Now that I’ve fixed the Gradle wrapper, I still can’t build anything due to missing licenses:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'JMEAndroidTemplate'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 23, Android SDK Build-Tools 24.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

Ah, yes, I think I needed to do the license agreements as well. I do not remember how I did it. I will do a google search now. Will get back to you soon.

Edit:

btw, @sgold have you updated build.gradle as said here?

Please make sure to remove this line

buildToolsVersion "24.0.2"
1 Like

Hi @sgold,
On my windows machine I am getting this.

java.lang.NoClassDefFoundError: jme3utilities/Validate

1 Like

@sgold can you try this:

Go into android-sdk/tools/bin/ directory open a terminal from there and run this command:

./sdkmanager --licenses

1 Like

I created 2 clones of the repo, one for testing and one for the PR. The PR repo did not have the build.gradle changes, and that’s the one that generated the licensing error messages I posted.

That class is provided by the Heart library. If you’re building with Gradle, there should be a dependency in Minie-1.5.0.pom that causes Heart-5.2.1 to be downloaded from JCenter, installed, and added to the build.

I am not using gradle as build system, I am using ant and the sdk.
Should I just manually download Heart?

1 Like