Slick Forums

Discuss the Slick 2D Library
It is currently Fri Aug 23, 2019 3:13 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue Jan 31, 2012 10:15 pm 
Offline

Joined: Tue May 03, 2011 10:38 pm
Posts: 32
So I've been struggling to get going with Slick-AE, and have been following the Intro to Slick AE thread thread, and Mr Kenkron has been graciously trying to help me figure this out. I build the slick-ae.jar using the files available on the Slick SVN.

If it helps any, I'm attempting to build for 2.3.3.

To explain my current situation, I have created a game with Slick2D back in May of 2011, so I attempted to use that, but I ran into an error at runtime (can't resolve the superclass of TestSlickAEActivity).

After some clarification from Mr. Kenkron regarding how to set up the projects, I have two projects in my workspace. One called zzTest which is the desktop game, and zzTestAndroid which is the Android project.

The desktop game is currently just the basic Slick2D game. Instead of the basic Slick2D set up, I now have in the lib folder (and included in the build path):
  • gdx-backend-lwjgl-natives.jar
  • gdx-backend-lwjgl.jar
  • gdx-natives.jar
  • gdx.jar
  • slick-ae.jar

And I changed the main to:

Code:
public static void main(String[] args) {
      try {
         ApplicationGDXContainer container=new ApplicationGDXContainer(new zzTest(), 360, 600, 360, 600);
         container.start();
      } catch (SlickException e) {
         e.printStackTrace();
      }
      
}

This compiles and runs fine as a Java application.

As for zzTestAndroid, it is set up as an Android project following the guidelines in Mr Kenkron's thread. In the lib folder it has:

  • armeabi
  • armeabi-v7a
  • gdx-backend-android.jar
  • gdx.jar
  • slick-ae.jar

gdx-backend-android.jar, gdx.jar, and slick-ae.jar are in the build path, as is the zzTest project.

In the Activity class of this project is:

Code:
package empowered.disarray;

import org.newdawn.slick.SlickActivity;

import blarghy.blargh.zzTest;

import android.os.Bundle;

public class ZzTestAndroidActivity extends SlickActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        start(new zzTest(), 360, 600);
    }
}


Yes, I have terrible naming conventions but this is just to try and get this going. blarghy.blargh is in fact my package name for zzTest. There are no problems listed in Eclipse up to this point.

When I run this as an Android application I receive these errors in Logcat:

Code:
01-31 16:42:34.446: E/dalvikvm(398): Could not find class 'blarghy.blargh.zzTest', referenced from method empowered.disarray.ZzTestAndroidActivity.onCreate
01-31 16:42:34.446: W/dalvikvm(398): VFY: unable to resolve new-instance 63 (Lblarghy/blargh/zzTest;) in Lempowered/disarray/ZzTestAndroidActivity;
01-31 16:42:34.456: D/dalvikvm(398): VFY: replacing opcode 0x22 at 0x0003
01-31 16:42:34.456: D/dalvikvm(398): VFY: dead code 0x0005-000f in Lempowered/disarray/ZzTestAndroidActivity;.onCreate (Landroid/os/Bundle;)V
01-31 16:42:34.496: W/dalvikvm(398): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/badlogic/gdx/backends/android/AndroidApplication;
01-31 16:42:34.576: W/dalvikvm(398): Class init failed in newInstance call (Lempowered/disarray/ZzTestAndroidActivity;)
01-31 16:42:34.576: D/AndroidRuntime(398): Shutting down VM
01-31 16:42:34.587: W/dalvikvm(398): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-31 16:42:34.626: E/AndroidRuntime(398): FATAL EXCEPTION: main
01-31 16:42:34.626: E/AndroidRuntime(398): java.lang.ExceptionInInitializerError
...

From the very first line, I notice that for some reason Dalvik cannot find the class for the game. This doesn't make sense to me as it's included in the build path. I've even tried checking everything off in Order and Export in hopes that it would include everything in the APK. It does not. I've also tried to create a jar from zzTest and include it in the build path for zzTestAndroid, but it gives me the same error.

I need some help in trying to figure out what's going on here and how I can fix it. I will continue to post my findings if I have any.

Thanks in advance!


Top
 Profile  
 
PostPosted: Thu Feb 02, 2012 4:40 am 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
To anyone who is reading this thread and has android experience, please help! I have been completely unable to answer this problem.

Also, not to give up on this problem, I do have another thing you can try. Export the android project into an apk, rename it to .zip, unzip it, see if the class files are missing, if they are, add them, and then rezip the project, rename it .apk, and see if that apk file will work.

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
PostPosted: Wed Feb 15, 2012 3:58 pm 
Offline

Joined: Tue May 03, 2011 10:38 pm
Posts: 32
I have a temporary working fix for this, and I have attached a zip containing sampleGame and sampleGameAndroid. The problem with this is that if anything is updated (slick2d, slick-ae, or libgdx) I have no real way of updating it.

(Download zip here)

Here is a guide on how to set up and use it. I'm assuming you've installed the Android SDK and Android USB for your device

1. Extract zip to desired location

2. In Eclipse, choose File > New > Java Project
- Project Name: sampleGame
- Uncheck Use Default Location
- Browse to the sampleGame and click OK
- Click Finish
- Double check the folder structure in Eclipse and make sure it looks like:

sampleGame
  • src
    • sample.game
      • DesktopLauncher.java
      • GamePlayState.java
      • MainMenuState.java
      • zzTest.java
  • JRE System Library (We're running with 1.6)
  • Referenced Libraries
  • libs
    • gdx-backend-lwjgl-natives.jar
    • gdx-backend-lwjgl.jar
    • gdx-natives.jar
    • gdx.jar
    • slick-ae.jar
  • res
  • defaultfont.fnt
  • defaultfont.png

3. In Eclipse, choose File > New > Project, then Android > Android Project and click Next
- Project Name: sampleGameAndroid
- Uncheck Use default location
- Browse to sampleGameAndroid and click OK
- Click Next
- Select Android 2.3.3 from the list of OS's (I've only tested this to work with 2.3.3)
- Click Next
- Package Name: sample.game
- Click Finish
- Click Yes when it asks you if you want to create the project in an existing blah blah blah...
- Click OK when it tells you AndroidManifest.xml already exists...
- Double check to make sure the file structure looks like:

sampleGameAndroid
  • Android 2.3.3
  • Referenced Libraries
  • src
    • sample.game
      • SampleGameAndroidActivity.java
  • gen
  • assets
    • defaultfont.fnt
    • defaultfont.png
  • bin
  • libs
    • armeabi
    • armeabi-v7a
    • gdx-backend-android.jar
    • gdx.jar
    • slick-ae.jar
  • res
  • AndroidManifest.xml
  • progaurd.cfg
  • project.properties

4. Set up your Android Emulator
- In Eclipse, go to Window > AVD Manager
- New
- Name: (Name this whatever you like)
- Target: Android 2.3.3
- Skin -> Built-in WVGA800
- Device ram size: 1024
- Click Create AVD

5. To test the project on the emulator:
- Open SampleGameAndroidActivity.java in Eclipse
- Click the arrow beside the run icon
- Run Configurations
- Click Android Application from the left sidebar and click the new icon on the top left ( looks like a piece of paper with a plus on it)
- Name: (Anything you want)
- Browse and select sampleGameAndroid and click OK
- Under the Target tab, check Automatic, and check the Emulator you just configured in 5.
- Click Apply, then Run
- You can now click the run icon whenever you want to debug the game
- If it doesn't automatically run, click the arrow beside the run icon and select the run configuration you made

5a. If you have an Android device, you can go back into the run configuration you made, under the Target tab and choose Manual. From now on after you've set that, a dialogue box will come up when you run the game to ask you if you want to run it on your device or run it on the emulator.


Top
 Profile  
 
PostPosted: Wed Mar 28, 2012 6:04 pm 
Offline

Joined: Tue Feb 21, 2012 3:46 pm
Posts: 26
I have got the same error!

[Solution]

Do not use JavaSE-1.7 ! I switched back to 1.6 and all was fine!!!


Top
 Profile  
 
PostPosted: Mon Oct 15, 2012 11:12 pm 
Offline

Joined: Sun Jun 12, 2011 2:27 pm
Posts: 90
How do I solve this problem?
I put 1.6 to compile

Log
Quote:
[2012-10-15 20:02:23 - sampleGameAndroid] ------------------------------
[2012-10-15 20:02:23 - sampleGameAndroid] Android Launch!
[2012-10-15 20:02:23 - sampleGameAndroid] adb is running normally.
[2012-10-15 20:02:23 - sampleGameAndroid] Performing sample.game.SampleGameAndroidActivity activity launch
[2012-10-15 20:02:23 - sampleGameAndroid] Automatic Target Mode: Preferred AVD 'Android10' is not available. Launching new emulator.
[2012-10-15 20:02:23 - sampleGameAndroid] Launching a new emulator with Virtual Device 'Android10'
[2012-10-15 20:02:24 - sampleGameAndroid] New emulator found: emulator-5554
[2012-10-15 20:02:24 - sampleGameAndroid] Waiting for HOME ('android.process.acore') to be launched...
[2012-10-15 20:02:55 - sampleGameAndroid] HOME is up on device 'emulator-5554'
[2012-10-15 20:02:55 - sampleGameAndroid] Uploading sampleGameAndroid.apk onto device 'emulator-5554'
[2012-10-15 20:02:59 - sampleGameAndroid] Installing sampleGameAndroid.apk...
[2012-10-15 20:03:20 - sampleGameAndroid] Success!
[2012-10-15 20:03:20 - sampleGameAndroid] Starting activity sample.game.SampleGameAndroidActivity on device emulator-5554
[2012-10-15 20:03:21 - sampleGameAndroid] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=sample.game/.SampleGameAndroidActivity }


Error..
Quote:
Sorry!
The Aplication SampleGameAndroid (process SampleGame has stopped unexpectedly. Please try Again).


::::::::: SOLVED :::::::::
He did not see the classes in another project


Top
 Profile  
 
PostPosted: Tue Oct 16, 2012 11:33 pm 
Offline

Joined: Tue May 03, 2011 10:38 pm
Posts: 32
Err which classes did I miss?


Top
 Profile  
 
PostPosted: Tue Oct 16, 2012 11:43 pm 
Offline

Joined: Sun Jun 12, 2011 2:27 pm
Posts: 90
It was the "SampleGame" put everything on the same project and it worked, as would the other solution? (using eclipse)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group