Minie for Androids

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