So I upgraded to the latest nightly and updated my project to remove all calls to GL10 but I am getting this error even though I have removed the reference to it.
Exception in thread "main" java.lang.NoSuchFieldError: useGL20
at com.me.mygdxgame.Main.main(Main.java:10)
This is what the code in the file looks like
package com.me.mygdxgame;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
public class Main {
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "my-gdx-game";
// cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;
new LwjglApplication(new MyGdxGame(), cfg);
}
}
Does anyone have an idea of why I still keep getting this error?
The latest libgdx build has gotten rid of the opengl 1.0 backend so the field cfg.useGL20 is no longer needed. If interested read up here
According to that page
LwjglApplicationConfiguration and AndroidApplicationConfiguration do not have the useGL20 flags anymore.
So eliminate that line and things should be good if you updated each project to the newest nightely. If you are still having problems update projects again to the newest nightly as this is very new to libgdx so there are probably a lot of bugs
Related
Here is my Desktop Launcher code:
public class DesktopLauncher {
public static void main (String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setForegroundFPS(60);
config.setTitle("Game10");
config.setWindowedMode(1240, 760);
config.forceExit = false; // ERROR!!!
new Lwjgl3Application(new GdxGame10(), config);
}
}
In new LWJGL3 config.forceExit not working. I can't find any solution so far. Any help is appreciated.
There is no forceExit in config. So presumably you have a master application that runs a child libGDX component and when you end that child component you find that the entire application shuts down, when you want the master application to continue. I guess you are on desktop because Android would be OK. So you must want to avoid a full System.exit
i.e.
Gdx.app.exit()
shuts down everything.
So when you instantiate a libGDX application you instantiate based on the application type, so for me, I use the same as you
final Lwjgl3Application application = new Lwjgl3Application(Services.GAME_CONTROLLER,config);
and the implementation for exit is
#Override
public void exit () {
running = false;
}
This finished the while loop that drives the application i.e. kills the main thread. If you have -other threads- running in the background they keep going.
If on the other hand you were instantiating LwglAWTCanvas then your shutdown would be this.
#Override
public void exit () {
postRunnable(new Runnable() {
#Override
public void run () {
stop();
System.exit(-1);
}
});
}
which would shut down the entire application. Anyway so forceExit being -false- was to stop a full system exit killing all your threads. The forceExit was to "force" the other threads to finish. It doesn't do that anymore so the fact it is now missing should not matter, your background threads should keep going.
In other words, config.forceExit = false; is now the default behaviour for your application type so you don't need it.
I am upgraiding a loader for external flash game(this loader is already written and it is working, but I have been using previous version of Flash Builder(not sdk!) to write it.
What I need is to see what classes of my code does not exist in the project... For now it just compiles everything with or without errors and does not shows any errors or warnings to me.
I think the example will show what I mean:
I have a working function wich compiles without errors:
protected function init(event:Event = null) : void
{
Living.movie.removeEventListener(Event.ADDED_TO_STAGE, this.init);
this.GamePlayer = Living.movie.parent.parent;
this.Map = this.GamePlayer.map;
this.Map.addEventListener(Event.REMOVED_FROM_STAGE, this.dispose);
}
I am making changes to this function:
protected function init(event:Event = null) : void
{
NotExistingClassOrVariable = OMGIT will compile and so on;
Living.movie.removeEventListener(Event.ADDED_TO_STAGE, this.init);
this.GamePlayer = Living.movie.parent.parent;
this.Map = this.GamePlayer.map;
this.Map.addEventListener(Event.REMOVED_FROM_STAGE, this.dispose);
}
and above function compiles without any errors too.... I can write anything inside a function body - it will compile(but it will not work ofcaurse)...
Please help me to solve this problem - trying to solve it already for 8 hours.
And sorry for my really bad english =(
Solved a problem by reinstalling flash builder. I do not know why it happened, but seem it was IDE bug.
For some reason, when I try to receive a shared property from a Worker (in AS3), the result is always null. That is, I send a value to a Worker using setSharedProperty(), when I retrieve it using getSharedProperty(), it always returns undefined/null.
Here's a simple test I set up:
package
{
import flash.display.Sprite;
import flash.system.Worker;
import flash.system.WorkerDomain;
public class Main extends Sprite
{
private var _worker:Worker;
public function Main():void
{
if (Worker.current.isPrimordial)
{
initMain();
}
else
{
initWorker();
}
}
private function initMain():void
{
_worker = WorkerDomain.current.createWorker(this.loaderInfo.bytes);
_worker.setSharedProperty("message", "test");
_worker.start();
}
private function initWorker():void
{
_worker = Worker.current;
var message:String = _worker.getSharedProperty("message");
trace(message);
}
}
}
When I trace message, the result is null. Although my main goal is to make an AIR app, I get the same result whether I'm compiling for AIR (3.7) or Flash Player (11.6, for some reason 11.7 doesn't recognise flash.system.Worker as a valid class).
I'm compiling using the Flex SDK, through FlashDevelop. Does anybody know what's wrong, maybe I've missed something in my code?
FlashDevelop now seems to have complete support for debugging workers which really wasn't the case on older versions (you could neither break, or trace inside workers). AIR SDK workers support has also progressed (I remember things working in release would break in debug version)
I just recompiled your sample with AIR SDK 14 release (14.0.0.110)
air14_sdk_win/bin/mxmlc -swf-version=25 -debug=true Main.as
and debugged it with Shockwave Flash Debugger 14,0,0,125 and FlashDevelop 4.6.1.30 and got the expected result:
[Starting debug session with FDB]
Created Worker 2
test
Beware that any element not up-to-date in your debugging chain (sdk/player/debugger) could result in problems for debugging workers
Does anyone know why the getDefinitionByName function works with "com.foo.Bar" and gives error with "com.foo.Rab"?
My only clue is that the class com.foo.Bar was created before importing the project to Flash Builder 4.5 for PHP (4.5.1 namely).
My question is very specific, in fact you could try for yourself if you had FB4.5.1, a prior version of the same program, and a lot of time. Obviously I’m hoping to find someone who have experienced this particular issue or any related issue with similar functions.
I'm porting a card game from pure Flash/AS3 to Flex 4.5 and in the original app I was using getDefinitionByName to load card MovieClips from the library dynamically:
var sprite:Sprite = new (getDefinitionByName(spriteName) as Class);
But in my Flex app I don't use it anymore. Instead I have this class - Assets.as:
package {
public class Assets {
[Embed('assets/Pref.swf', symbol='spades_Q')]
public static const SPADES_Q:Class;
[Embed('assets/Pref.swf', symbol='clubs_Q')]
public static const CLUBS_Q:Class;
[Embed('assets/Pref.swf', symbol='diamonds_Q')]
public static const DIAMONDS_Q:Class;
[Embed('assets/Pref.swf', symbol='hearts_Q')]
public static const HEARTS_Q:Class;
....
and then in my main class I use:
var sprite:Sprite = new Assets[spriteName];
for example:
var sprite:Sprite = new Assets['HEARTS_Q'];
Maybe this helps you?
getDefinitionByName can only import classes that are already present in the current ApplicationDomain. Your app must import com.foo.Rab in the normal fashion earlier in the execution or it will not work.
I developed some JUnit tests that extend org.apache.struts2.StrutsTestCase. I used the tutorial on struts.apache.org as my starting point.
Everything was working fine until I modified my simple web application to use Tiles. I have Tiles working fine in the app but now my Action test cases have stopped working.
I'm getting NullPointerException at org.apache.struts2.views.tiles.TilesResult.doExecute when I run the following line of code:
ActionProxy proxy = getActionProxy("/displaytag.action");
The log shows the Struts 2 Action is executing succesfully until it tries to hand it off to TilesResult.doExecute.
I suspect it is because the tests run outside of the container and the tiles.xml is only referenced in the web.xml and therefore my StrutsTestCase tests don't know where to find the definitions in tiles.xml.
Is this making sense?
I'm using Struts 2.2.1.1 and the tiles related jars (v. 2.0.6) included in the Struts distribution.
I'll include a code snippet from my StrutsTestCase but please note everything runs successfully when I run the app from the browser in Tomcat, it only fails when I run the StrutsTestCase outside of Tomcat. And the test cases ran successfully before I added Tiles.
public class TagActionTest extends StrutsTestCase {
static Logger logger = Logger.getLogger(TagActionTest.class);
public void testCreateTagFail() throws Exception {
logger.debug("Entering testCreateTagFail()");
try {
request.setParameter("name", "");
ActionProxy proxy = getActionProxy("/createtag.action");
TagAction tagAction = (TagAction) proxy.getAction();
proxy.execute();
assertTrue("Problem There were no errors present in fieldErrors but there should have been one error present", tagAction.getFieldErrors().size() == 1);
assertTrue("Problem field 'name' not present in fieldErrors but it should have been",
tagAction.getFieldErrors().containsKey("name") );
} catch (Exception e) {
logger.debug("Error running testCreateTagFail()");
e.printStackTrace();
assertTrue("Error running testCreateTagFail()", false);
}
}
Partial stack trace:
java.lang.NullPointerException
at org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)
Lastly, can anyone explain what the deal is with StrutsTestCase? There's a tutorial page for using it with Struts 2 on struts.apache.org but the SourceForge page for it hasn't been updated since Struts 1.3 Also, what's the difference between StrutsTestCase and MockStrutsTestCase
I imagine you're initialising tiles with a listener:
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
You need to initialise that Listener in your tests. I found a few others with the same issue [1].
The code below is in your class that extends StrutsSpringTestCase. You need to override the setupBeforeInitDispatcher. In the code snippet below, the override sets the applicationContext attribute (also needed if you're using spring) and initialises Tiles (inside the if(tilesApplication) segment, where tilesApplication is a boolean so you can toggle this code on an off based on your whether or not your application runs with tiles ):
/** Overrides the previous in order to skip applicationContext assignment: context is #autowired
* #see org.apache.struts2.StrutsSpringTestCase#setupBeforeInitDispatcher()
**/
#Override
protected void setupBeforeInitDispatcher() throws Exception {
//init context
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
if(tilesApplication){
servletContext.addInitParameter(BasicTilesContainer.DEFINITIONS_CONFIG, "WEB-INF/tiles.xml");
final StrutsTilesListener tilesListener = new StrutsTilesListener();
final ServletContextEvent event = new ServletContextEvent(servletContext);
tilesListener.contextInitialized(event);
}
}
[1] See http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
It is trying to display the jsp page. So disable by adding ExecuteResult(false) in the code.
So, add the below line
proxy.setExecuteResult(false);
before proxy.execute()