Cannot find assets when running libgdx app on android, works fine on desktop - android-studio

After getting out of a mode of procastinating, I've finally gotten to the item on the projects todo-list that says "Run on virtual device to see why it crashes".
My project is a libgdx application that I plan on porting to various platforms, the two most important ones being desktop and android.
During development I've exclusively used the desktop launcher, as it's a lot easier to fire up when just checking minor things.
I did build an .apk at one point just to see if it'd run out of the box, but it didn't. Now that I've tried via the virtual device, this is what the log says:
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: rifleman.png
The same goes for any other assets that my game uses. The files are all placed in projectname/android/assets, as I remember learning way back that this was the way to go.
The virtual device I tried with is the stock Nexus 5, but I tried running the .apk by uploading it to my actual phone with a crash right after start, and I assume the problem is the same and is therefore unrelated to the test-platform.
I am currently not using an assetmanager, as implementing this is scheduled for after getting the basic core mechanics up and running. In the mean time I'm loading them as such: new Pixmap(new FileHandle("rifleman.png"));
Using android-studio 2.2 on Linux Mint 17 Cinnamon.
Please comment if more info is needed.

Use Gdx.files.internal() instead of FileHandle().
From filehandle(string) method info
Creates a new absolute FileHandle for the file name. Use this for
tools on the desktop that don't need any of the backends.
Do not use this constructor in case you write something cross-platform.

Related

Is it possible to execute local .exe´s from angular application running in browser?

We are about to start a new project which should be like a desktop app but still run inside a browser for creating items in a system. After these items are created, an .EXE file on the LOCAL machine must be called to do some code generation. Is this possible if using Angular to develop the application or do we need third party libs for executing local .exe's?
No, this is not possible out of the box. Browsers make very sure that local executables cannot be started. You would have to look for other solutions.
One possible idea, depending on how much effort you want to invest, would be to compile the WebKit engine yourself, i.e., create a binary "wrapper" which runs the browser engine itself. Then you are free to extend it in whatever fashion you need, including adding the possibility to start local .exe's (or if those .exe's are your own applications, you could compile them right into your WebKit wrapper).

How to automatically update a deployed Node JS Electron program

I think the title should be quite self-explanatory. I am developing a Node JS app using Atom Electron. What I would need is a way to deploy my application in a cross-platform way (Mac OS X, Windows and Linux), while making it capable of automatically updating itself, without having to ask for administration privileges.
Here is what I would like to happen:
The application gets installed by my users, possibly via an easy-to-use installer.
I keep developing my app, adding new features, and so on.
At some point, I release a new version of my code, I pack it somehow and upload it somewhere.
All the clients that are currently online, or whenever a client gets back online, they download the new version, install it, and restart automatically, without having to ask for administration privileges.
As far as I know, there are apps that are capable of doing such a thing. For example, Google Chrome automatically installs updates without having to continuously ask for administrative privileges or, even worse, making its users download new installers all the time.
Is there an elegant and cross platform way to do such a thing? What would be the best solution for my problem?
If this is matters in any way, let me add that my project is completely open source, so I don't care about protecting my code in any way from being read.

run codenameone j2me application on samsung devices

I create j2me application with codenameone and it works well in Nokia phones, however I wanna install or run it on Samsung devices (for instance S8300) I'll get error.
How can I fix this error?
I searched for this device's details and I found it doesn't have operting system but it can run java with MIDP2.0. What can I do for these device types? How can I run it on these devices?
Thanks in advance.
Check that you didn't use Java 5 language features and limited yourself to the CLDC 1.1 API specification in terms of classes such as java.util.
Codename One includes support for these features which work well on Nokia where the VM is more compliant but fails on some devices when these features are used.
Several things things may be the problem:
1) the jar file is to big. Java device have often constraints for max size of jar file, some of them unbelievable small. try to install a smaller jar file, like a hello world.
If this is problem, make sure you use "obfuscate", as it also removes unused code from the jar file.
2) Depending on operator branding, Samsung devices often do not allow to install the jar file directly from PC (with bluetooth or usb cable) :-(
What is possible only is called OTA-Download. There you need to create a jad file and a jar file, put them on a webserver, and call the url from jad in the mobile browser of the device.
You need to change the MIDlet-Jar-URL inside to have the absolute url of the jar file on your web server.
This is all quite complex. to check that your webserver is correctly set up and that that jad file has no syntax errors, you can use my jad checker:
jadcheck.appspot.com
We must create UI by hard coding not using lwuit or codenameone designer.
cause of some devices that don't have an OS and just support MIDP can't run these type of applcations which are create by lwuit or codenameone desiner.
Maybe it cause of resource file path in devices!

Java ME Application running fine in Emulator but crashing when deployed to N70. Any way to identify the reason for crashing?

I have developed a Java ME application for CLDC platform. It works fine when executed in an emulator. But when i deploy it to my N70 phone the application doesn't start at all in the phone. In my application there are some 14 classes and am creating an instance of each and putting them in the vector on application start. The classes just have one variable and 2 methods. Can this creating of lot of instances be the reason for its crashing?
Is there any way I can find out the reason why the application is not able to start in the phone?
Update:
Its running fine on emulator. And one more thing I would like to mention is that- The code stops executing only at the point where am creating those 14 instances and adding them to the vector. Till that point the code executes fine.
It might depend on where in the code you are creating those instances. If you are creating them in your MIDlet constructor or the startApp method try moving the initialization into the run method of your application.
One way of debugging J2ME applications that don't start on the phone is by adding "printf" style debug messages in your code to be written in the record store system and adding another MIDlet to your application to read from RMS and display those messages.
Or you could just comment bits of code and see if it works.
You can debug on device. If the emulator you are using is part of the Nokia SDK then there should be facilities elsewhere to carry out on-device testing and debugging. (I'd post more detail on this but I've only done this with Sony Ericsson phones recently.)
Another option is to use the Nokia tools that allow you to view the standard output and error for your application when it is running on your device (via Bluetooth for example).
The probability that your application is actually crashing the Java Virtual Machine bytecode interpreter thread and terminating the whole native process is very small.
It has happened before but you need to eliminate several other potential issues before being convinced of an actual crash.
It is more likely that either:
Your MIDlet is not created or not started because the MIDP runtime decides it is not correct.
or
Your MIDlet simply throws an exception that you don't catch, which can make it look like it was brutally terminated.
Since the MIDlet installer is supposed to prevent you from installing a bad MIDlet, the uncaught exception issue is more likely.
How to find an uncaught exception:
Start with the simplest HelloWorld MIDlet, using a Form so you can easily insert more StringItems at the top of the screen.
Create and start a new Thread in MIDlet.startApp()
In your override of Thread.run(), add a try{}catch(Throwable){} block.
Inside that block, do whatever your original MIDlet did.
Use the form as your standard output for debugging.
You can use Form logging to make sure you don't enter an infinite loop, to display exception classes and messages, to flag logical milestones, to display variable values...
That's the first step to figuring out what is going on.
I also faced a similar problem and when I recompiled my MIDLET as Midlet 1.0 then it worked fine. It seems like N70 is not able to run the new version of MIDLET. I think you downgrade and re-test your midlet.
Regards
Junaid

j2me SDK3 for AWT/Swing application

I try to development an embedded application with Eclipse + J2me SDK3 + CDC.
When I am trying to create a Frame or JFrame, there is an error says "Could not read environment variable SUBLIME-PROC-ID".
Who know what's the problem?
Thanks in advance
I am not going to do some phone development.
I just want to do some embedded application which with AWT or Swing or SWT GUI. It is ok when it runs in Eclipse environment.
But When it runs without the eclipse, the problem is "Could not read environment variable SUBLIME-PROC-ID". (I run it under the CDC environment)
You will want to get a J2ME plugin for Eclipse, but I have found that doing J2ME development is easier using Netbeans.
I haven't use a frame in J2ME, but you may want to just use a Canvas.
Here is a relatively simple example of doing some frame animation on J2ME.
http://www.roseindia.net/j2me/frame-animation.shtml
If you are using the Personal Profile then you can develop much as you would with JavaSE, but I don't know if you are going with that.
UPDATE:
Toward the end of this post a comment was made that SUBLIME-PROC-ID was defined in a bash configuration file, and when that was removed the error went away.
You may have it defined somewhere in one of your configuration files, so you may want to look for that. I have never heard of this environment variable, so you may want to change your tags to have something about run-configuration or something in it, to help others out.
http://forums.java.net/jive/thread.jspa?messageID=353367

Resources