Jmonkey 3.1 + AdMob + Google play services

The biggest problem is that google’s play services and admob is now converted to use the gradle build system.

My suggestion and this is still a work in progress, is to create your game in jME3.1 sdk.
Then when you have a working game that is running on PC I would open up Android Studio.

I would create a SimpleAndroidApplication with only one activity.
Change that activity to look like the one jME generates. Taking into account you add all resources needed.
Also make sure you add the android project at the same file path as the jME game.

Then in the android app’s build.gradle file, change the script to add the following:

  1. Add the google play services dependency to the gradle script
  2. Add the admob dependency to the gradle script
  3. Add a task to copy all the jME generated jar’s in the games dist folder. (…GamePath/dist/libs) “NB: Exclude the generated assets.jar”
  4. Add a task to copy the game jar generated by jME. (…GamePath/dist/mygame.jar)
  5. Add a task that will copy the Assest folder of your game to android.

I think that is the basic idea and I am sure you can use it to get started. Good luck!

Here is my build.gradle file:


apply plugin: 'com.android.application'

ext {
    gamePath = "../../Driver-Game"
    gameJar = "OneTouchDriving.jar"
}


android {
    signingConfigs {
        bruynhuiskey {
            keyAlias 'xxx'
            keyPassword 'xxx'
            storeFile file('C:/workspaces/privatework/gitprojects/bruynhuisandroidstudio/bruynhuis-key')
            storePassword 'xxx'
        }
    }
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "com.bruynhuis.driver"
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 3
        versionName "1.2"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.+'
    compile 'com.google.android.gms:play-services:9.0.2'
    compile 'com.android.support:multidex:1.0.0'
}

task ClearGameJar(type: Delete) {
    delete 'libs/' + gameJar
}

task copyGameJar(type: Copy) {
    from gamePath + '/dist/' + gameJar
    into 'libs'
}

task ClearJMEJars(type: Delete) {
    delete fileTree('libs') {
        include '**/*.jar'
    }
}

task copyJMEJars(type: Copy) {
    from(gamePath + '/dist/lib') {
        include '*.jar'
        exclude 'jME3-desktop.jar'
        exclude 'assets.jar'
    }
    into 'libs'
}


task clearAssets(type: Delete) {
    delete 'src/main/assets'
}

task copyAssets(type: Copy) {
    from(gamePath+'/assets') {
        include '**/*.*'
    }
    into 'src/main/assets/'
}





project.afterEvaluate {
    prepareDebugDependencies.dependsOn(ClearJMEJars, ClearGameJar, clearAssets, copyJMEJars, copyGameJar, copyAssets)
}
1 Like