Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  [SOLVED]libGDX resources problem  (Read 3780 times)
0 Members and 1 Guest are viewing this topic.
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Posted 2013-01-04 02:55:33 »

Sorry if this is in the wrong section. If it is, can someone please put it in the right one. Anyway, when I try using libGDX and I put my resources in the android project, I get an error that says:
Couldn't load file apple.png (that is one of the resources).  Huh
Can you please help me
Thanks

Smiley
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 131
Projects: 4
Exp: 3 years



« Reply #1 - Posted 2013-01-04 03:13:24 »

Ok, source at least? File loading is so basic that you must be doing something wrong in your code (and I thought you were learning LWJGL).

Resources go in the assets folder, and you have to make a linked folder in the desktop project with the assets folder in the android project, otherwise resources will have to be synced manually (copy+paste).

For loading from the assets folder you must use Gdx.files.internal (not sure exactly what local does but stick to internal), make sure you're not using Gdx.files.absolute as that will require a full directory (e.g. C:/Users/User/EclipseWorkspace/...)
 

<a href="http://www.youtube.com/v/nOQt94fcoFo?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/nOQt94fcoFo?version=3&amp;hl=en_US&amp;start=</a>
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #2 - Posted 2013-01-04 03:15:58 »

Code here. I used the  setup jar

Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 131
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2013-01-04 03:18:52 »

You seem to be loading the textures correctly so I assume it must be a problem with your project setup.
Is "apple.png" in the Android "assets" folder AND in the desktop "assets" folder? (Did you link the folders? If you didn't you should)
Did you hit refresh on the android project, and the desktop project if the assets folder isn't linked?

Oh yeah, and this is definitely the wrong section. Why would a libgdx resources problem go under OpenGL Development? Huh
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #4 - Posted 2013-01-04 03:21:16 »

I refreshed and it isn't in both folders. The problem remains

Smiley
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 131
Projects: 4
Exp: 3 years



« Reply #5 - Posted 2013-01-04 03:22:30 »

Can you see the picture in eclipse, under the project?
Offline badlogicgames
« Reply #6 - Posted 2013-01-04 03:26:00 »

Use the setup-ui to create your Eclipse projects. Here's a video tutorial http://code.google.com/p/libgdx/wiki/ProjectSetupNew

In short: run the gdx-setup-ui.jar, fill in the values for project names etc. in the UI, hit generate, import the Eclipse projects into your workspace and all will be well.

Your Android project's asset/ folder will contain the real assets, the desktop and other projects link to that folder.

http://www.badlogicgames.com - musings on Android and Java game development
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #7 - Posted 2013-01-04 03:33:45 »

@badlogicgames: I did that.
@Jimmit: I can't

Smiley
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #8 - Posted 2013-01-04 03:43:49 »

I made a project using the setup jar. I then put all my stuff into the android assets. I imported the project into eclipse. I then copied the code from my former project into my new one. i could see the pictures (and music) in the assets folder in eclipse. It still doesn't work.

Smiley
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 131
Projects: 4
Exp: 3 years



« Reply #9 - Posted 2013-01-04 03:45:45 »

Like I said, you need to link the assets in the android to the assets in the desktop...does the ui do that? Never used it.
Full error trace? Maybe you're using OpenGLES 1 and your image's dimensions aren't a power of 2?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #10 - Posted 2013-01-04 03:48:20 »

I set it to GL20. It still doesn't work.

Smiley
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #11 - Posted 2013-01-04 04:02:46 »

This is the stack trace on the console in eclipse:
(I couldn't find the other part)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: apple.png
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn'
t load file: apple.png
   at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
   at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
   at com.badlogic.gdx.graphics.Texture.load(Texture.java:175)
   at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
   at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
   at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
   at com.me.mygdxgame.Munch.create(Munch.java:35)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:125)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: apple.png (Internal)
   at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:127)
   at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:566)
   at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:215)
   at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
   ... 8 more

Smiley
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #12 - Posted 2013-01-04 04:40:56 »

I am so stupid!! (whacks hand on forehead) I forgot to put the /data in front of the paths!!  Cranky
Thanks for your help anyway.  Grin

Smiley
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 131
Projects: 4
Exp: 3 years



« Reply #13 - Posted 2013-01-04 04:43:55 »

Please, try to debug the obvious before asking. You should have seen the data folder in the eclipse project structure, and we can't see what's on your computer.
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.

BurntPizza (16 views)
2014-09-19 03:14:18

Dwinin (34 views)
2014-09-12 09:08:26

Norakomi (61 views)
2014-09-10 13:57:51

TehJavaDev (84 views)
2014-09-10 06:39:09

Tekkerue (42 views)
2014-09-09 02:24:56

mitcheeb (64 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (39 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!