ClassNotFoundException

Okay, so I’ve got my APK exported and signed, but when I try to run it I get this error message.
[java]java.lang.ClassNotFoundException: mygame.MainApplication[/java]

Here is my main and my mainactivity.
[java]package com.ggworkshop.hexprototype;

import com.jme3.app.AndroidHarness;
import android.content.pm.ActivityInfo;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import com.jme3.system.android.AndroidConfigChooser.ConfigType;
import mygame.MainApplication;
import mygame.Controller;

public class MainActivity extends AndroidHarness{

private int deviceId;
private AssetManager assetManager;

/*
 * Note that you can ignore the errors displayed in this file,
 * the android project will build regardless.
 * Install the 'Android' plugin under Tools->Plugins->Available Plugins
 * to get error checks and code completion for the Android project files.
 */

public MainActivity(){
    // Set the application class to run
    appClass = "mygame.MainApplication";
    // Try ConfigType.FASTEST; or ConfigType.LEGACY if you have problems
    eglConfigType = ConfigType.BEST;
    // Exit Dialog title & message
    exitDialogTitle = "Exit?";
    exitDialogMessage = "Press Yes";
    // Enable verbose logging
    eglConfigVerboseLogging = false;
    // Choose screen orientation
    screenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    // Invert the MouseEvents X (default = true)
    mouseEventsInvertX = true;
    // Invert the MouseEvents Y (default = true)
    mouseEventsInvertY = true;
}

[/java]
and,
[java]package mygame;

import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetManager;
import com.jme3.bullet.BulletAppState;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Node;
import java.util.ArrayList;

/**

  • MainApplication class, calls app states to start game.

  • @author
    */
    public class MainApplication extends SimpleApplication {

    private static MainApplication app;
    protected Camera _cam;
    protected AppStateManager appStateManager;
    protected BulletAppState bulletAppState;
    protected Node _rootNode;

    private boolean init = false;

    /**
    *
    */
    protected DayNight day;

    public static void main(String[] args) {
    getApp().start();
    }

    public static MainApplication getApp() {
    if (app == null) {
    app = new MainApplication();
    }
    return app;
    }

    // Sets up essential functions and components
    @Override
    public void simpleInitApp() {

     assetManager = getAssetManager(); 
     inputManager = getInputManager();
     appStateManager = stateManager;
     
     /** Set up Physics */
     bulletAppState = new BulletAppState();
     appStateManager.attach(bulletAppState);
     bulletAppState.setEnabled(true);
     
     day = new DayNight(rootNode);
     
     _cam = cam;
     _rootNode = rootNode;
     
     //flyCam.setEnabled(false);
     flyCam.setMoveSpeed(50);
     flyCam.setEnabled(true);
    
     MenuAppState x = new MenuAppState(bulletAppState, app, appStateManager, inputManager, assetManager, _rootNode, _cam);
     stateManager.attach(x);
     x.setEnabled(true);
     
     init = true;
    

    }

    /**

    • Note: Player is just a simple object I just made up to represent a player
      */
      ArrayList players = new ArrayList();

    /**

    • Adds a player to the game to be associated with the specified controller
    • @param controller the controller used by the player
    • @return true if the player object is successfully added to the game
      */
      public boolean addPlayer(Controller controller) {
      synchronized (players) {
      if (init) {
      Player nPlayer = new Player(controller, “Models/test_box/test_box.j3o”);
      players.add(nPlayer);
      return true;
      }
      }
      return false;
      }

    boolean mainMenu = false;
    boolean gameState = false;

    @Override
    public void simpleUpdate(float tpf) {

     day.cycle();
    

    }

    @Override
    public void simpleRender(RenderManager rm) {
    //TODO: add render code
    }

     public BulletAppState getBulletAppState() {
     return bulletAppState;
    

    }
    }
    [/java]

Any help is much appreciated. I’ve tried messing with my android manifest as well, but it only caused more problems.

I’m facing the same problem - Android can’t find the application class. :frowning:
Does anyone know how to deal with this problem?

The classpaths should be correct:
MainActivity: package com.destroflyer.roblocks; (equal to the classpath specified under “Properties” → “Mobile” → “Android”) and appClass = “com.destroflyer.roblocks.application.MainApplication”;
MainApplication: package com.destroflyer.roblocks.application;

I’m using Android 2.3 and the stable RC2 release of the SDK.

E/AndroidHarness( 1056): Class com.destroflyer.roblocks.application.MainApplication init failed
E/AndroidHarness( 1056): java.lang.ClassNotFoundException: com.destroflyer.roblocks.application.MainApplication
E/AndroidHarness( 1056): at java.lang.Class.classForName(Native Method)

I got this before, this issue is often the consequence of another issue. (there must be some errors just before the classdefnotfound, not exceptions)
last time i got it was because i had compile jme3 core with java 7 and somehow android was not pleased with that.
I compiled it with java 6 and all worked again.
Now if you didn’t do this, there must be some library issue in your project

Thanks for the hint, I called setIcons and setTitle on the settings - I thought, Android would just ignore them… (Unfortunately, it rejected the corresponding method and therefore the whole class => ClassNotFoundException)
Now, it loads a little bit longer, but then crashes when loadng a nifty screen:

I/NiftyLoader( 1284): internal prepare screen (levelCompleted) [3]
W/System.err( 1284): java.lang.NullPointerException
W/System.err( 1284): at com.jme3.asset.AndroidImageInfo.loadBitmap(AndroidImageInfo.java:94)
W/System.err( 1284): at com.jme3.asset.AndroidImageInfo.getBitmap(AndroidImageInfo.java:38)
W/System.err( 1284): at com.jme3.texture.plugins.AndroidImageLoader.load(AndroidImageLoader.java:14)
W/System.err( 1284): at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
W/System.err( 1284): at com.jme3.asset.AndroidAssetManager.loadTexture(AndroidAssetManager.java:114)
W/System.err( 1284): at com.jme3.niftygui.RenderImageJme.(RenderImageJme.java:56)
W/System.err( 1284): at com.jme3.niftygui.RenderDeviceJme.createImage(RenderDeviceJme.java:151)
[…]
W/System.err( 1284): at de.lessvoid.nifty.Nifty.loadFromFile(Nifty.java:528)
W/System.err( 1284): at de.lessvoid.nifty.Nifty.addXml(Nifty.java:487)
[…my call of addXml…]

There’s only one image in the according screen:
[xml]











[/xml]