New jMonkey activity in existing android project

Hi. I am entirely new to both Android coding and jMonkey, so I apologise if the questions I am going to ask are going to sound daft to the majority of you.

I have an existing android app. Does not do much at the moment, just browsing files on memory card and opening them. I wanted to add another activity that would use jMonkey to display some stuff (mostly simple geometries as cubes and spheres) based on the content read from the file that’s opened. I created a simple test jMonkey application (displaying just one cube for now) and added it to my project library, I added the jMonkey android library and then I defined a new “class Viewer extends AndroidHarness” (as by the example posted on this website). I also added the Viewer activity to AndroidManifest.xml. However every time I try to launch the Viewer with a new Intent, I get a ClassDefNotFoundException

Any idea how to achieve this? Thanks in advance for any help or suggestions

Mauri



I forgot to mention I am using Eclipse for my android project.

There’s something missing from your classpath. Without telling us which class couldn’t be found its impossible to know which dependency you’re missing but my guess is that the Android jar isn’t present.

Apologies, I have not been clear enough. Android jar is present and the class that cannot be found is the Viewer class which is defined

[java]package com.myname.myapp

import com.jme3.app.AndroidHarness;

public class Viewer extends AndroidHarness

{

public Viewer()

{

// Set the application class to run

appClass = "com.myname.mytestviewer";

//eglConfigType = ConfigType.FASTEST; // Default

// Edit 22.06.2011: added a switch to get the highest (best) egl config available on this device

// Its usually RGBA8888

eglConfigType = ConfigType.BEST;

// Exit Dialog title & message

exitDialogTitle = "Exit?";

exitDialogMessage = "Press Yes";

// Edit: 25.06.2011: Enable verbose logging

eglConfigVerboseLogging= true;

// Edit: 30.06.2011: Choose screen orientation

screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;

// Edit 12.07.2011: Invert the MouseEvents X (default = true)

mouseEventsInvertX = true;

// Edit 05.07.2011: Invert the MouseEvents Y (default = true)

mouseEventsInvertY = true;

}

}[/java]



I also added it to AndroidManifest.xml as activity but that did not help.

I’ve found the android stuff in the jme sdk to work but be very fiddly/sensitive.



As a starting point I’d recommend just creating a new simple game and following the “deploy for android” instructions on the wiki. Once that is working and deploying you then have something working to use as a base.

I’m a bit lost. I followed zarch’s advice: create the a basic Android app following the tutorial. I created the basic game, enabled the Android deployment, built and run, but again I get a

java.lang.ClassNotFoundException: com.mycompany.mygame.MainActivity


I am obviously not getting this :(

I’m having the same problem:



W/dalvikvm( 9392): Unable to resolve superclass of Lcom/game/supergame/MainActivity; (9)

W/dalvikvm( 9392): Link of class ‘Lcom/game/supergame/MainActivity;’ failed

W/dalvikvm( 9392): threadid=1: thread exiting with uncaught exception (group=0x40018560)

E/AndroidRuntime( 9392): FATAL EXCEPTION: main

E/AndroidRuntime( 9392): java.lang.RuntimeException: Unable to instantiate activity







I’m going to try to get it running in an emulator at least - but does anyone know what the problem is? This is my third try.

It cannot run in an emulator, the emulator doesn’t support opengl 2

I knew that at one point, but wasn’t thinking when I posted. Anyway, I get the error trying to run my game on a phone. The regular Android sample (not JME) works fine.

I’m not running this on emulator, but on a phone and a tablet both supporting opengl 2

All I can say is that it works for me…so long as I’m careful to:


  1. Create new simpleGame
  2. Get the project fully setup
  3. then turn on the android deployment
  4. Don’t touch any settings!
  5. Do not try and turn android deployment off then back on again!!



    I know that’s hardly a ringing endorsement but as I said I’ve found the android deployment to work really well once it is set up but to be fiddly/sensitive to get configured.

If you have issues, try opening the “Important Files” node and add the following line to the “Android Properties” file:

[java]external.libs.dir=libs[/java]

I found out that in the latest android SDK (17) the libs folder is broken somehow…

I managed to make it package them by adding this at the bottom of the android build file:

[xml] <target name="-post-package">

<package-helper>

<extra-jars>

<jarfolder path="${jar.libs.absolute.dir}" />

</extra-jars>

</package-helper>

</target>

[/xml]

1 Like

Still nothing. It says “unable to resolve superclass of …/MainActivity” - I assume that means it somehow isn’t linking AndroidHarness (and maybe other parts of JME)?



Thanks for your help.

I started a new thread, seems like the libs folder is broken in Android SDK r17, and ideas would be helpful.

1 Like