0
\$\begingroup\$

I'm trying to use libgdx to set up a little quiz application for Desktop.

So I used the setup.jar to create a project and everything went fine (using Eclipse).

The problem is following:

Whenever I try to access the assets in core/assets, as you should do: Gdx.files.internal(filePath)

I always get a NullPointerException:

java.io.FileNotFoundException: PATH\QuizApplication\desktop\questions.xml (The system cannot find the file specified)

My assets Folder in the desktop project is linked to the core project, and inside Eclipse, I can see the right contents. As you can see from the Exception, the application tries to read the desktop project instead of the core project.

In build.gradle in the desktop project, the link to the core assets folder is there too:

project.ext.assetsDir = new File("../core/assets");

Does anyone know how I might fix this problem, so that I can access the core/assets folder?

\$\endgroup\$
3
  • \$\begingroup\$ You probably need to set your working directory to the assets folder. Read this answer: stackoverflow.com/questions/26195511/… \$\endgroup\$ Apr 18, 2018 at 8:56
  • \$\begingroup\$ Thanks,that fixxed it! Now I'm having other problems concerning packaging the Application with gradlew. I guess I'll start from scratch and test everything step by step to see where I made a mistake. \$\endgroup\$ Apr 19, 2018 at 16:02
  • \$\begingroup\$ If you found a solution to own question, you can post an answer yourself. \$\endgroup\$
    – wondra
    Apr 19, 2018 at 19:16

2 Answers 2

1
\$\begingroup\$

I could fix the problem by using these two questions:

https://stackoverflow.com/questions/26195511/libgdx-project-cant-find-assets-folder

https://stackoverflow.com/questions/22822767/file-not-found-when-running-new-libgdx-project?noredirect=1&lq=1

I guess the gdx-setup.jar does everything for you except directing the Workspace the right way.

My second problem in the comments could be fixxed by using a lower Java JDK (1.8.0_151).

\$\endgroup\$
0
\$\begingroup\$

I was also able to resolve this by changing the active directory to the subproject. For example instead of running gradle in your base project, you can change the current directory to the subproject.

For example

Task that fails due to OP issue

./gradlew task

So instead...

cd subproject
../gradlew task

worked for me.

(note I'm using gradle wrapper thus I had to point it back to it's local in the main project with ../, if you're just using gradle you won't need this.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .