Why won't my libgdx generated project run? - libgdx

I created a libgdx project for android desktop HTML and iOS with the libgdx gradle setup then i imported it in eclipse. I tried to run the desktop application with no changes and this is what eclipse outputs.
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
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:130)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:88)
at si.borenovic.igor.samplegame.SampleGameMain.create(SampleGameMain.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 9 more

This is because libgdx doesn't find the image file "badlogic.jpg". To do this you shoud add a link in your desktop application from the assets folder in the Android app.
In this link it is explained better how to do it:
http://www.badlogicgames.com/wordpress/?p=1537

If you are using Eclipse and you, upon import, select the "COPY EXISTING PROJECTS INTO WORKSPACE" option, you are creating a new copy of the projects under a new path.
The project files don't update the references to those paths... so you either need to update the reference manually (see above) or do not copy into the workspace, pointing to the original gdx-setup generated project location.

Related

Android Studio Gradle error: Missing project_info object

basically opening this question again because the answer is outdated, as the link now redirects to Firebase:
Gradle fails building with "Missing project_info object"
I want to attach the google-services.json file to my Android Studio project, and every time I try to download it from the developers API from Google, it gives me a json file with a large name that does't correspond to the tutorial's simple "google-services" and renaming it won't work because of this error.
Downloading it creating a new project doesn't seem possible for me now as it the page gives me another error when I click Configure a Project (I already did that before but left the project there without downloading the json file directly from there, which seems to be the problem).
Where can I safely get this file, and should I rename it or? Thanks in advance.
Apparently the solution is just following the link and creating the project with Firebase:
Then create or select a project and fill it with your app data that shoul look like this (the SHA-1 key should be found in your console log when clicking the button in the image:
Then add the lines of code that should be in your build.gradle(app level one and project level one), editing them with notepadd. Finally you need to sync these Gradle files, in Android Studio : File->Sync project with Gradle Files
The tutorial is very self explatanory, but for beginners like me, this could help.

Deploy support files from secondary assembly

I'm, porting a phone application written using MVVMCross to Windows RT. The application uses SQLite and has a database that is not empty at deploy so I want it to be packaged in the installation folder anc copied to LacalFolder when the application starts.
The database really belongs to the "Core" assembly shared between phone and WinRT but if I put the file in the Core project (in a custom directory called Data), define it as Content and set the Copy Always flag the file does not get copied to the application installation folder.
If I put the file in a directory under the UI project the file gets copied as expected. Any suggestion to avoid keeping two files for the same resource (and the troubles this will cause) ?
Thanks for help
Windows 8 WinRT projects by default use the Content type which does loose packing of files (they are not included in the assembly). If your Core assembly is part of your solution as a project - VS will properly package it copying all the content to the "Core" subfolder of the appx. If you simply have the dll file referenced in your solution - the resource files will not be packaged. The solution in that case is to do something to get these additional files to deploy with the dll. One option is to package the dll as a .vsix together with the assets as described in Tim Heuer's blog post. Another is to do what you did and put the file in the app project. You can add the file to the app project "As Link" to avoid having a copy of the file - it makes Visual Studio create a sort of logical/symbolic link to the file instead of creating a copy - simply right click a folder in the Solution Explorer/app project, select "Add/Existing Item", browse to the file and instead of hitting the "Add" button - use the dropdown triangle on the button to select "Add As Link".

FDT - Create a Project with existing source files, assets, folders etc

I am using FDT 5 and would like to create a new project with already existing source files and assets. When I start up the Project Wizard (New->FDT Project) I browse to the folder I want to make as the project but I cannot proceed as FDT gives me the error:
*"PROJECT_NAME overlaps the location of another project: PROJECT_NAME"*
I have downloaded a flash project (developed in FDT) and would just simply like to make it a project in my FDT environment.
I mean this shouldn't be so complicated right? I don't want to create an entirely new project (its own folder) I want to use the same folder I downloaded and view that project. I am using git so I have to work in the same path, sort of speak.
Any ideas?
EDIT:
Apparently this is an issue with FDT, a small bug. I managed to solve the problem following this:
FDT / Eclipse Error : ‘overlaps the location of another project’
And on the eclipse forum:
Eclipse Forum

how access actionscript file in a different project?

I have two ActionScript projects in Flash Builder 4.5. The second project needs to use some of the actionscript files in the first project. Is there a way to do this without duplicating those files in the second folder? Is library project the answer? Any details appreciated.
I use Library projects for this type of sharing. It works well.
Create a new library project
File -> New -> Flex Lilbrary Project
Any files that you want to be shared can go into that project. I tend to organize it by folder, depending on what the classes do. (example: Views, Models, DTOs, Utilities, etc).
The output will be a SWC file in the bin folder.
Manually referencing the library project
If you aren't actively developing the library project, you can build it and drop it into the libs folder and use the classes like you normally would.
If you are like me and you are constantly working on the library projects, then I like to set it up so that the projects actually reference each other in a way that changes to the library project don't require a manual step.
Automatically referencing the library project
In the project that wants to reference the library project, do the following:
Go to Project Properties -> Flex Build Path -> Add SWC Folder
Add /LibraryProjectName/bin
Go to Project Properties -> Project References
Select the library project
That's it
Once you set it up this way, you can share files via the library project. I do this all the time. Reasons you might want to do this:
Library Project: MyProject.Behavior
Web Project: MyProject.Web
Mobile Project: MyProject.Mobile
Desktop Project: MyProject.Desktop
Administrator Desktop Project: MyProject.Administrator
Testing: MyProject.Specs
As you can see, I can have several projects that all use the same behavior (models, views, etc).
you can make a library project, and add this output library file into library of used project, and add this library used project by adding library in Eclipse.
Making library project sample:
http://cookbooks.adobe.com/post_Creating_a_Flex_Library_Project_in_Flash_Builder-17629.html
Or
you can share reference of the library project by adding reference project in Eclipse, it works fine to me.
HTH.

Adding an external jar library to Intellij IDEA

I'm having a silly problem : I'm trying to add the Jsoup library (which is just an external jar) to my android application developed in Intellij Idea and it seems and don't do it right .
I put the library in the libs folder , then I went in Project Structure -> modules and selected dependencies , select add global library , select attach source and click ok.
When I write code it is able to automatically import classes and to compile , but when running I get " java.lang.NoClassDefFoundError: org.jsoup.Jsoup"
Copy the .jar file into your lib/ directory.
Right click the new .jar in the lefthand file browser in IntelliJ / Android Studio
Choose "Add as Library..."
Voila!
-Open the External Libraries node on the Left hand panel.
-Select Open Library Settings
-Project structure dialogue opens up.
Select the Libraries.
Click the "+" to browse the file.
![add external jar1
In IntelliJ IDEA 15 you can also access the Project Structure menu item from "File" item in the menu bar. Select Libraries from the list on the left. Click the "+" to browse the file, select it and you're done. It will be added to the "External Libraries" directory in your project.
Have a look at the newer artifacts section. Perhaps you don't add the JAR into your deployment properly.
UPDATE:
I'd like to update my answer based on lessons learned over the past six years since I first answered this question.
The best way to manage 3rd party JAR dependencies in Java projects is to learn Maven (my preference) or Gradle. IntelliJ has terrific integration with both.
If you combine those with an enterprise repository like Nexus you'll have no problems. Your dependencies and versions will be completely specified. Conflicts will be identified for you. Updates will be relatively simple.