Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Images + Libgdx + Loading in Android + NetBeans  (Read 1157 times)
0 Members and 1 Guest are viewing this topic.
Offline Andre Lopes
« Posted 2013-05-23 13:43:17 »

Greetings beloved Forum.
I seeka tha halp of the lords of the words for tha issue.

Ok, seriously, Tongue
I was able to make android emulator run, but whenever i tell it to execute it says " main activity has stopped unfornat..." , im almost sure its because the images im loading. Im probably loading them in a wrong way.Also, idk where to put them in the projects folder.

I have a spriteManager class that is where i have all the imgs loaded :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
public class SpriteManager {

    //REFERENCE EXP MODEL
    private ExplosionModel explosionModel;

   
    //Create Textures
    private Texture explosionTexture;
    private Texture myPlane;
    private Texture enemyPlane;
    private Texture myMissile;
   
   
   
    public SpriteManager() {
       
        explosionTexture = new Texture(Gdx.files.internal("ExplosionSheet.png"));
        myPlane = new Texture(Gdx.files.internal("plane.jpg"));
        enemyPlane = new Texture(Gdx.files.internal("enemyOrangePlane.jpg"));
        myMissile = new Texture(Gdx.files.internal("missileArthur.jpg"));
       
        //
        explosionModel = new ExplosionModel(this);
    }


But i dont know where to put the images in the project.
In java Desktop, i know i need to put in same folder than the .jar , but what about android?

I got a free book of android development, but i will just be able to start studying it in end of June, due to stuff...
Offline davedes
« Reply #1 - Posted 2013-05-23 13:57:43 »

What is the LogCat output?

IMHO the easiest way to run LibGDX projects on Android is to use the Android Bundle:
http://developer.android.com/sdk/index.html

This is a version of Eclipse which is all set up for Android and includes various useful plugins. All you need to do is use the LibGDX setup tool, import the project into Eclipse, and run your project-android activity.

If you want to continue using NetBeans or another IDE, you just need to ensure that your "internal" files are in the class-path. Generally you would put a folder like "data" in your android project, then reference the file as so: "data/img.png".

Offline alaslipknot
« Reply #2 - Posted 2013-05-23 14:03:25 »

In java Desktop, i know i need to put in same folder than the .jar , but what about android?
hello,
i don't think it's necessary to put them in the same folder with the .jar, you just have to create a folder in your workspace, put your resources in it (graphics,sounds) and then make that folder a "source folder" (that's how it works in Eclipse i don't know for NetBean)
and for now try to write the complete path of your image (c:\texure.png) just to know if the problem is due because your program doesn't find the image or maybe it's something else .
PS :
i found this article i think it can be helpful for you

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Andre Lopes
« Reply #3 - Posted 2013-05-23 14:07:01 »

Hm, i need to make that logCat output appears.
I will try to do as you said, probably should work.

Heres a Screeshot i took from the screen, of how it is now :
http://img705.imageshack.us/img705/5353/androidbug.jpg

Offline Andre Lopes
« Reply #4 - Posted 2013-05-23 14:15:20 »

Ok, i created a folder in the project , called images and i put all imgs inside it.

Logs :
Maybe this can help :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
ant -f D:\\AndroidProjects\\PlaneShooterAndroid debug
Android SDK Tools Revision 22.0.0
Installed at C:\adt-bundle-windows-x86_64-20130514\sdk
Project Name: PlaneShooterAndroid
Project Type: Application
Using latest Build Tools: 17.0.0
Resolving Build Target for PlaneShooterAndroid...
Project Target:   Android 4.2.2
API level:        17
WARNING: No minSdkVersion value set. Application will install on all Android versions.
----------
Creating output directories if needed...
----------
Resolving Dependencies for PlaneShooterAndroid...
Library dependencies:
No Libraries
----------
Building Libraries with 'debug'...
No sub-builds to iterate on
Found Deleted Target File
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
Handling aidl files...
No AIDL files to compile.
----------
Handling RenderScript files...
No RenderScript files to compile.
----------
Handling Resources...
Found Deleted Target File
Generating resource IDs...
----------
Handling BuildConfig class...
No need to generate new BuildConfig.
Compiling 3 source files to D:\AndroidProjects\PlaneShooterAndroid\bin\classes
input: D:\AndroidProjects\PlaneShooterAndroid\bin\classes
input: D:\AndroidProjects\PlaneShooterAndroid\libs\gdx.jar
input: D:\AndroidProjects\PlaneShooterAndroid\libs\gdx-natives.jar
input: D:\AndroidProjects\PlaneShooterAndroid\libs\gdx-backend-android.jar
Using Pre-Dexed gdx-c92b75ddbf68ddcaa64b3370f28c3dc2.jar <- D:\AndroidProjects\PlaneShooterAndroid\libs\gdx.jar
Using Pre-Dexed gdx-natives-7e3449b13aa1b2187bb11427d61f2d37.jar <- D:\AndroidProjects\PlaneShooterAndroid\libs\gdx-natives.jar
Using Pre-Dexed gdx-backend-android-112f3fd67126d8a51f2631203eb4bfd6.jar <- D:\AndroidProjects\PlaneShooterAndroid\libs\gdx-backend-android.jar
Found Deleted Target File
Converting compiled files and external libraries into D:\AndroidProjects\PlaneShooterAndroid\bin\classes.dex...
Merged dex A (21 defs/16,8KiB) with dex B (727 defs/1210,7KiB). Result is 748 defs/1565,3KiB. Took 0,4s
Merged dex A (748 defs/1565,3KiB) with dex B (125 defs/236,5KiB). Result is 873 defs/2408,3KiB. Took 0,2s
Crunching PNG Files in source dir: D:\AndroidProjects\PlaneShooterAndroid\res
To destination dir: D:\AndroidProjects\PlaneShooterAndroid\bin\res
Crunched 0 PNG files to update cache
Found Deleted Target File
Creating full resource package...
Found Deleted Target File
Creating PlaneShooterAndroid-debug-unaligned.apk and signing it with a debug key...
Running zip align on final apk...
Debug Package: D:\AndroidProjects\PlaneShooterAndroid\bin\PlaneShooterAndroid-debug.apk
Updating property file: D:\AndroidProjects\PlaneShooterAndroid\bin\build.prop
Updating property file: D:\AndroidProjects\PlaneShooterAndroid\bin\build.prop
Updating property file: D:\AndroidProjects\PlaneShooterAndroid\bin\build.prop
Updating property file: D:\AndroidProjects\PlaneShooterAndroid\bin\build.prop
debug:
CONSTRUÍDO COM SUCESSO (tempo total: 5 segundos)


1  
2  
3  
4  
5  
Starting activity Start.Start.MainActivity on device emulator-5554
Starting activity Start.Start.MainActivity on device emulator-5554
Starting activity Start.Start.MainActivity on device emulator-5554
Starting activity Start.Start.MainActivity on device emulator-5554
Starting activity Start.Start.MainActivity on device emulator-5554


wait wait wait wait and same error.



But look at this :
1  
2  
3  
Resolving Dependencies for PlaneShooterAndroid...
Library dependencies:
No Libraries


I guess thats the issue, it isnt exporting the libraries.. Stupid netbeans.
Offline alaslipknot
« Reply #5 - Posted 2013-05-23 14:21:08 »

{this was before you post your last reply}
Heres a Screeshot i took from the screen, of how it is now :
http://img705.imageshack.us/img705/5353/androidbug.jpg



you shouldn't put your images there,look,
the thing here is that your program will not look there to find the images, you should put them in the "res" folder, i think libGdx created for you, isn't that right ? and as i said, just try to load 1 image with it's full path, it should be like this :
1  
 myPlane = new Texture(Gdx.files.internal("d:\AndroidProjects\PlaneShooterAndroid\plane.jpg"));
 

Question to libGdx experts,
isn't one of the main libGdx feature is that you code once and then you can diploid it in many platformer without having to worry about things like that ? so if he was able to load image in the desktop version, why he can't with android ?

{after it}
why you don't try Eclipse ?? almost all the libGdx tutorial are using Eclipse, am not trying to say that eclipse is better, but i tried libGdx for 2 or 3 days only and i didn't find any trouble loading my own images,
by the way, the "hello world" libGdx is loading an image as a background, when you tried it on netBean, did it work on the Android ??

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Offline Andre Lopes
« Reply #6 - Posted 2013-05-23 14:30:10 »

I will try with eclipse later but, heres something interesting, i made a little test and same error happened , still in netbeans :


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
package Start.Start;

import View.AndroidTest;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;

public class MainActivity extends AndroidApplication
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        //System.out.println("Working?");
        super.onCreate(savedInstanceState);
        initialize(new AndroidTest(),false);
    }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
package View;

import android.graphics.Color;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;

/**
 *
 * @author André Vinícius Lopes
 */

public class AndroidTest implements ApplicationListener{

    public void create() {
         Gdx.gl.glClear(Color.WHITE);
    }

    public void resize(int i, int i1) {
     
    }

    public void render() {
        Gdx.gl.glClear(Color.WHITE);
    }

    public void pause() {
       
    }

    public void resume() {
       
    }

    public void dispose() {
       
    }

}
Offline alaslipknot
« Reply #7 - Posted 2013-05-23 14:41:57 »

i think all your troubles are a setup issue, either you are not having all the requirement to run android app or there is something wrong with your libGdx native libraries (or both)
my suggestion to you is that you try to run an example that you are 100% sure that it has no mistake in the code (use google to find some good ones), if the errors still appears then you will know that you were not doing anything wrong except that netBean and Android are not correctly configured .
good luck

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years



« Reply #8 - Posted 2013-05-23 15:47:36 »

I'm 90% certain it's a project setup prblem. I've used libgd. For a while with several projects and never have I had a successful android run, even after setting up with the setup jar. Oh well, I only dev for desktop anyways Smiley
Offline Andre Lopes
« Reply #9 - Posted 2013-05-23 19:52:12 »

Alright, i ran some tests and it worked with other projects.
It appeared etc.

So, i took the triangle libgdx example and run it.
It worked.

So what i did was , to copy the codes to the triangle package. Once i did that, several errors started happening.
it didnt recognize spriteBatch and requested other import, instead of the normal that i commonly use.
It didnt recognize animation as well.It requested android.Animation import etc...

Little Example :
1  
2  
3  
cannot find symbol
  symbol:   method setColor(Color)
  location: variable font of type BitmapFont


idk whats happening.
Unless.... the lib that is inside the project is old?
Good idea, i will try  to replace it and see what happens.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Andre Lopes
« Reply #10 - Posted 2013-05-23 20:02:28 »

That was it.
It seems that it was all because of the version.
After i Replaced the libs, i made a little test and it worked another test class, but when i test the game it says its stopped. Well, I think im closer to find whats happening.

I bet now its all because of the image loader, so i will keep messing with it until i find out.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (37 views)
2014-12-15 09:26:44

Mr.CodeIt (30 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (59 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!