Gdx.files.internal not using android assets path - libgdx

Whenever I try to use Gdx.files.internal to get a FileHandle, I am getting a FileNotFoundException like follows:
<PATH TO MY GAME>\desktop\xml\screen.xml (The system cannot find the path specified)
I set my project up using the libgdx project setup tool, and it seems that my asset folder within my desktop project is the same as my android project (they're linked). However, when I go to my desktop project there is a bin folder with my assets. If I change the path to "/bin/..." then I can run the project without any exceptions. However, I feel this may be a problem if I export as a JAR.
Code:
final FileHandle screenXML = Gdx.files.internal("xml/screen.xml");

My problem stemmed from the following (credit goes to the awesome and patient IRC community members for Libgdx):
// final Document screenDoc = docBuilder.parse(screenXML.file());
// Note: MUST use .read() here, not .file(), as we link from the android assets!
final Document screenDoc = docBuilder.parse(screenXML.read());

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.

How to set Image Source to a picture from .dll or .winmd in windows phone 8.1?

I am new to windows phone 8.1 developping and focus on library dev.
In the wp 8.0 era,I know if I want to create a Image instance.
I just write
amapLogo.Source = new BitmapImage(new Uri("/Com.AMap.Api.Maps" + ";component/Resources/ap2.data", UriKind.Relative));
need to point here is that "/Com.AMap.Api.Maps" is my library output dll
It works fine.
If I keep the same code in wp8.1 developping
exception appears
An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: The given System.Uri cannot be converted into a Windows.Foundation.Uri. Please see http://go.microsoft.com/fwlink/?LinkID=215849 for details.
I browse http://go.microsoft.com/fwlink/?LinkID=215849
and find that two ways to set the ImageSource correctly.
the ms-appx or ms-appx-web scheme to create an absolute URI.
but it is used for getting a resource in the app package
what I want is getting a resource from my dll
so
What can I do to create a Image instance using way of setting
ImageSource.
Or is there anther way to do what i want?
Thanks!
Just Solve it!
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965322.aspx
To access files stored inside the same package, but from a class library, use the class library name:
<Image Source="/ClassLibraryName/images/logo.png" />

Name Not Found Even if Exists in the JSON file Updated

There is a runtime error which keeps telling me that the name have not been found. Take a look at this error:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.RuntimeException: Name 'lame' was not found.
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: java.lang.RuntimeException: Name 'lame' was not found.
at aurelienribon.bodyeditor.BodyEditorLoader.attachFixture(BodyEditorLoader.java:79)
at com.bodapps.shootme.physics.controller.BodyPhysicsSettings.setGoalPostBody(BodyPhysicsSettings.java:32)
at com.bodapps.shootme.view.GameScreen.show(GameScreen.java:273)
at com.badlogic.gdx.Game.setScreen(Game.java:59)
at com.bodapps.shootme.Start.create(Start.java:11)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:125)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108)
This error came from this code. Take a look and see comment on code below.
goalPost1 = wc.getWorld().createBody(def1);
goalPost1.setActive(true);
goalPost1.setGravityScale(0);
goalPostLoader1.attachFixture(goalPost1, "lame", fixtures1, 5); // --> Under the same JSON filenamename and added and updated this name "lame." However, this is where it stops here.
goalPost2 = wc.getWorld().createBody(def2);
goalPost2.setActive(true);
goalPost2.setGravityScale(0);
goalPostLoader2.attachFixture(goalPost2, "soccer ball", fixtures2, 5); // --> This name, also in the same JSON filename. Even it has a space, it should be worked too.
The JSON filename "ball physics.json" and this is where I took it from the Physics Body Editor engine.
Here's the code from the JSON file.
{
"rigidBodies":
[
{
"name":"soccer ball",
"imagePath":"../images/soccer ball.png",
"origin":{"x":0,"y":0},"polygons":[],
"circles":[{"cx":0.5,"cy":0.5,"r":0.4756574332714081}],
"shapes":[{"type":"CIRCLE","vertices":[{"x":0.5,"y":0.5},{"x":0.5250000357627869,"y":0.02500000037252903}]}]
},
{
"name":"lame",
"imagePath":null,
"origin":{"x":0,"y":0},
"polygons":[[{"x":0.625,"y":0.05000000074505806},{"x":0.625,"y":0.949999988079071},{"x":0.3499999940395355,"y":0.949999988079071},{"x":0.3499999940395355,"y":0.05000000074505806}]],
"circles":[],
"shapes":[{"type":"POLYGON","vertices":[{"x":0.3499999940395355,"y":0.05000000074505806},{"x":0.3499999940395355,"y":0.949999988079071},{"x":0.625,"y":0.949999988079071},{"x":0.625,"y":0.05000000074505806}]}]
}
],
"dynamicObjects":[]
}
I registered the name "lame" after editing from the Physics Body Editor that saves as JSON file. Unfortunatelly, the programming software cheats on me even if I'm correct. Please, help me fix it as soon as possible.
Updated question! (As of 4/11/2013)
I wonder if the assets in the Desktop starter project folder matches with or it has the same and directory with the Android starter project folder? If that case, does the updating files added in the assets folder in project folder (Android starter) automatically updates in the Desktop starter project folder or not?
Due to the problem in updating at the Desktop starter project folder, the image files and JSON file was not directly from Android's assests automatically copied to Desktop's assets! In case of this problem, I have to manually copy it. It's the only best thing I could ever do. From the Android assets folder, select the specified file and directory (folder) and copy it to the assets folder in Desktop. Make sure that the directory and filename is correct.

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