I primarily use LibGDX to develop games for Android. It is helpful to test on the desktop. When I do so, I just set the "desktop" project in Android Studio to use the assets from the "android" project, as described here. This works great on my local machine for testing purposes. However, it won't work if I want to package my game and release it for other's to play on their own machines. How do I go about packaging my game to include the graphic and audio assets?
I stumbled on the following snippet in the build.gradle file:
task dist(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
}
}
This appears to bundle project.assetsDir into the JAR file created by the dist task which is set as
project.ext.assetsDir = new File("../android/assets");
To run the above task from the command line, type
gradlew desktop:dist
Related
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.
I have been trying to compile StrobeMediaPlayback from source; I've managed to compile the project using ANT with the Flex 4.5.1 or Flex 6 SDK and also successfully compiled using Flash Builder 4.5 (as recommended by the project).
In all cases, compiling the SMP project results in a 433k StrobeMediaPlayback.swf. Also, StrobeMediaPlayback.swf located in src/player/StrobeMediaPlayback/bin/StrobeMediaPlayback.swf ships as 433k. My question then, is how on earth do I compile StrobeMediaPlayback.swf to 253k as it exists in the for Flash Player 10.1 folder? It appears there is an external OSMF.swc file in this folder that is 233k - typically this gets bundled with the build... however, I can drop the 253k StrobeMediaPlayback.swf into a new project without the OSMF.swc file and it works fine.
So, if it turns out that I need to compile StrobeMediaPlayback without bundling the OSMF.swc, can someone point me in the right direction on how to do this?
Relevant installation documentation that was impossible to find: http://osmf.org/dev/osmf/specpdfs/building-osmf.pdf
So, if it turns out that I need to compile StrobeMediaPlayback without bundling the OSMF.swc, can someone point me in the right direction on how to do this?
Try,
in your StrobeMediaPlayback project, mark the osmf.swc as an external library.
(Project > Properties > Application Build Path > Library Path > OSMF > Link Type)
Can you please provide some guide how to create DriveQuickstart demo application (https://developers.google.com/drive/quickstart-android, steps 2-3) in Android Studio?
The problem is that Android Studio can't find com.google.api.* classes, like com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential. And I can't find it neither in google-play-services.jar, not in Android SDK folders.
I use "Compile with: Google APIs 17" in Android Studio, I downloaded all the latest updates in SDK manager (including Google APIs for API17, Google Play services, Google Repository).
According to http://developer.android.com/google/play-services/setup.html I added
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.google.android.gms:play-services:4.1.+'
}
in build.gradle. What other actions should I perform to compile the sample source code, add some external library? You have provided great detailed steps for Eclipse, but said nothing about Android Studio with Gradle.
Try adding this to project build.gradel,worked for me in android studio 0.4.3,
sync and then optimize imports(Ctrl+Alt+O) in windows.
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.google.android.gms:play-services:4.1.32'
compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
Credits go to user #smokybob
In the Quickstart, did you follow all of the items in Step 2?
Specifically it looks like you missed out the last two (confusingly numbered 1 & 2 which install the Google Client Libs into your project. Open the "libs" folder in your project and check that you have a bunch of client libs such as "googleapi-client.jar".
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
Flash builder project files can't be opened on another computer even if the files were copied, for e.g. through version control like git or svn.
Importing and Exporting fxp projects is not possible as we do not want to overwrite files for git or svn unnecessarily.
How do people collaborate on Flash Builder projects without creating new project in Flash Builder and having to set up all the settings for the project again and again for multiple collaborators?
If you import the project using its folder location as per #Sean Fujiwara answer then:
One useful way to collaborate in Flash Builder projects is to utilise environment variables. You can access these using - Window > Preferences > General > Workspace > Linked Resources:
From here you can add a new variable or edit an existing one, from the example above you can see that we use a FRAMEWORK_SOURCE variable which points to the source for our shared framework code, we use a swc but this is handy for debugging errors.
We also have another variable called OUTPUT_FOLDER which in our case points to a folder where we run our project over localhost see example below, to use this in a project, you go to right click project name > Properties > ActionScript Build Path, here you enter the folder name you want creating inside the folder that OUTPUT_FOLDER points to:
When you do a Project > Clean from the menu, all resources from your html-template folder will be copied across to this folder and it should open in a browser.
Now we have been able to check in to SVN our .project and .actionScriptProperities files with few issues. When someone new to the project checks them out, they will get an Error in the Problems panel telling them they don't have for example - OUTPUT_FOLDER\MyProjectName, therefore the project leader should have a document listing all the required variables to be setup in your environment.
Other things you can share are paths to raw font files etc.
The only problem I've had with this approach is sometimes it asks for the path to the SDK if it is different from your location, not had chance to figure this one out yet.
Flash builder project files can't be opened on another computer even
if the files were copied, for e.g. through version control like git or
svn.
Flash builder projects can be imported into the workspace just like other Eclipse projects.
Once you copy them to another computer:
Right click in package explorer and go to Import....
Select General/Existing Projects into Workspace.
Select the folder containing the .project directory.
If you make sure Copy projects into workspaces is deselected, you can commit the files directly from wherever you checked the code out.
This is now solved in Flash Builder 4.7 where you can actually import the project folder as is.