Gradle problems with JMonkeyEngine3 + Android Studio 3 (Canary 6)

TL;DR: why does not launching the desktop project work in my sample project GitHub - noncom/jme_android_example_as3_canary6 in Android Studio 3 Canary 6?

Currently I am working on Android projects with JME and there was time when I successfully setup a project for development under Android Studio 2 (feel free to use this example as a starting point for your AS2 project): GitHub - noncom/jme-android-example

However, time goes along and Android Studio 3 is arriving. So I have created the same kind of a base project in Android Studio 3 Canary 6: GitHub - noncom/jme_android_example_as3_canary6

All is fine except that the desktop project does not work anymore. I don’t get any errors in the studio itself, but trying to run the DesktopLauncher class fails with a SimpleApplication: NoClassDefFoundError message that indicates that it cannot see the JME libraries from there. Try it out and see.

I did not manage to find any cure for this problem. If I remove other projects (app and core) from the settings.gradle file, and move the Game class to desktop, then these projects disappear and the error goes away. That makes it look like if the IDE can only actually process dependencies for a single project.

NOTE: This is not a JME problem in itself. The same thing happens with any other library used in the same pattern. I have successfully reproduced the same behavior for Googles “Gson” library. However, I am bringing this here up since it is not completely unrelated either. And, besides, when it is fixed, the template can be used by people to easily setup their projects within Android Studio 3 with all its new features (like Kotlin). Or maybe I am missing something obvious (although I’ve already spent hours looking for info on Gradle and experimenting).

THIS ? ON G+: https://plus.google.com/109276295736585566471/posts/gqojQpFfHJT

THIS ? IN GOOGLE ISSUE TRACKER: https://issuetracker.google.com/issues/63629970

1 Like

Hello!

Nice initiative.

I din’t even get to launch the desktop - until I configured the build. Run configurations | Add Application and set com.example.noncom.jme_android_example_as3_canary6.DesktopLauncher as main class.

Then desktop worked.

However, the Android app crashes with
E/com.jme3.app.AndroidHarness: SEVERE Class com.hey.wow.Game init failed
java.lang.ClassNotFoundException: com.hey.wow.Game
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at java.lang.Class.forName(Class.java:326)
at com.jme3.app.AndroidHarness.onCreate(AndroidHarness.java:244)
at android.app.Activity.performCreate(Activity.java:6679)

If I change

public class MainActivity extends AndroidHarness {

public MainActivity() {
    // Set the application class to run
    appClass = "com.hey.wow.Game";

to

    appClass = "com.example.noncom.jme_android_example_as3_canary6.Game";

then it works

This is AS 3.0 beta 5.