This is a strange one! On my old desktop, I was able to build and run my libGDX project for HTML5 using the gradlew html:dist gradle command.
I uploaded the files to my site and everything worked well.
But on my laptop I synced the project via GitHub to Android Studio, ran the same command and it appears that the default ApplicationListener runs instead of my own custom one.
The only thing that appears is a red rectangle: http://johnathongoss.com/jaggybattles/
The desktop and android versions run and build fine on my laptop.
I'm using Android Studio and the latest version of libGDX.
Here is some code:
public class HtmlLauncher extends GwtApplication {
#Override
public ApplicationListener createApplicationListener() {
return new MyGame();
}
#Override
public GwtApplicationConfiguration getConfig () {
GwtApplicationConfiguration cfg = new GwtApplicationConfiguration(1280, 720);
return cfg;
}
}
//MyGame Class (Doesn't seem to get this far?)
#Override
public void create() {
camera = new OrthographicCamera(VIRTUAL_WIDTH, VIRTUAL_HEIGHT);
setScreen(new LoadingScreen(this)); //Loads the assets and sets Main Menu Screen
}
I've had this problem before but it was because I didn't change the createApplicationListener() method to return my own custom ApplicationListener. Now it seems to return the right one, I really don't know what could be causing this.
I should point out I can't access my desktop computer anymore due to relocating.
Any advice would be gratefully received!
Edit: Loading Class
https://gist.github.com/jaggygames/79b1bd821f4203aadecfe5e8ba925150
Assets Class:
https://gist.github.com/jaggygames/5b863f1692b0974b769d5694b5a3334f
MyDistance Font Class
https://gist.github.com/ea7b5965488cd5672e9e7c20917df9a1
Related
I have been trying to call a Java method in unity. Not working for me, even the simplest example from the docs
using System.Collections;
using UnityEngine;
public class ExampleClass : MonoBehaviour {
void Start () {
AndroidJavaObject jo = new AndroidJavaObject ("java.lang.String", "some string");
int hash = jo.Call<int> ("hashCode");
Debug.Log ("hash=" + hash);
}
}
Unity console prints hash=0, which is not the hash code for provided String. Even if I change and use java.lang.StringInvalidClass as class name, unity still reports same result to the console without notifying errors. I can even try to call toString, toStringa, toInvalid2 and they always return empty string without showing errors.
This is a brand new 2d project with only script displayed above, attached to camara object. I am using Ubuntu, Unity 2019.4 and project platform is Android.
Thanks for the assistance.
Answering myself after some time working with unity.
All examples in the web and unity documentation doesn't mention it, which is weird since it is something simple to mention and about confusions: code needs to run as an android application. Editor or even unity remote does not work, in order to use AndroidJavaObject and related classes, your code needs to run as an android application installed in the phone.
I am trying to launch an external application for testing using UISpec4J.
Here are the questions and their answers I referred so far:
How to automate a swing java web start application which runs clicking a link into a web application, which is automated with Selenium WebDriver?
Getting all windows using UISpec4J
UISpec4J Capturing modal dialog, before the trigger finish
my.exe referred below is a Java application wrapped in exe using some tool. Internally it uses the jars and is Java GUI application.
This executable launches a splash screen first, then a dialog to choose where you want to connect to and after that main window is shown. Unless I can automate where I can connect to I won't get main window.
Based on these questions I have come up with following code fragments:
this.setAdapter(new UISpecAdapter() {
#Override
public Window getMainWindow() {
return WindowInterceptor.run(new Trigger() {
#Override
public void run() throws Exception {
// running jnlp by netx launcher
Runtime.getRuntime().exec("C:\\my.exe");
Thread.sleep(10000);
}
});
}
});
In the approach above I simple get "No window was shown" error.
this.setAdapter(new UISpecAdapter() {
#Override
public Window getMainWindow() {
final Window[] result = new Window[1];
WindowInterceptor
.init(new Trigger() {
#Override
public void run() throws Exception {
Runtime.getRuntime().exec("C:\\my.exe");
//Thread.sleep(10000);
}
})
//.processTransientWindow()
.process(new WindowHandler() {
public Trigger process(Window window) throws Exception {
result[0] = window;
return Trigger.DO_NOTHING;
}
})
.run();
return result[0];
}
});
In the second approach above, I still get "No window shown" error AND control never reaches to overriden "process" method.
I referred to http://www.uispec4j.org/reports/apidocs/org/uispec4j/interception/WindowInterceptor.html and recommended approach is to use init to capture modal dialog is init\process sequence.
To capture non-modal it is recommended that we should use following:
Window window = WindowInterceptor.run(panel.getButton("open").triggerClick());
But I have NO idea where and how I am supposed to call it..
From the first question I referred, mentioned above, we should be able to do that because the answer to it mentions launching jnlp application which is external application.
I tried with jre 6 update 0 and I can at least run test. In java update 37, from the third question I referred above, I get abstract method not implemented error.
What am I doing wrong? Any idea?
I am using latest UISpec4J package - version 2.4.
Thanks in advance,
-Neel.
I'm very new to UISpec4J but I'm guessing it needs to run in the same JVM in order to intercept and interact with the GUI components. When you start the exe file with exec, it will create a new process and a new, separate JVM. That'll not work, if I understand UISpec4J correctly.
Regarding the non-modal example, the documentation says "You would retrieve the window from within the test...", so in a setup method or in a test should work.
I am following the Wicket user guide's "Hello World" project.
Wicket is in DEVELOPMENT mode.
When I change the HomePage.html and reload the browser, the change is not shown. If I restart the WicketApplication, then the changes are shown.
My application is at localhost 8080
All my research shows that changes should be loaded automatically when the application is in DEVELOPMENT mode (which it is).
I have not changed any configuration from the default Wicket installation.
No, if you deploy your app into app-server (like tomcat, glassfish, etc.), then the real .html's that shows in browser located somewhere in app-server folders.
For glassfish it can be "/path_to_glassfish/glassfish/domains/domainXX/applications/APP_NAME/WEB-INF/classes/...".
So, even if you change .html's at your project, you must to redeploy this changes.
Wicket JavaDoc says :
if the configuration type is DEVELOPMENT, resources are polled for
changes...
Yes, but is holds for resources located at appropriate folders. I think this wicket forum thread will give you some answers of how to implements behavior you want. This post is actually for old wicket version, but I think it is suitable for newer versions too.
In our company we use firebug or chrome console to stylize components right in browser without redeploying app, and this is enough for us, because static components rarely added on the html page.
Here is the solution I found.
For the class reloading issue, I run the "Start" application through Debug mode in IntelliJ. When in Debug mode, IntelliJ reloads classes that have changed.
For the HTML reloading issue, I put the following code in the WicketApplication init() method:
// add your configuration here
getResourceSettings().setResourcePollFrequency( Duration.ONE_SECOND);
getResourceSettings().setDefaultCacheDuration(Duration.ONE_SECOND);
List list = new ArrayList();
list.add( new IResourceFinder() {
#Override
public IResourceStream find( Class<?> clazz, String pathname ) {
File f = new File( "C:/MyProject/src/main/java/" + pathname );
if ( f.exists() ) {
return new FileResourceStream( f );
}
return null;
}
} );
getResourceSettings().setResourceFinders( list );
getResourceSettings().setUseDefaultOnMissingResource(true);
I came up with a different solution. Because I'm using Google App Engine, when I add the code
getResourceSettings().setResourcePollFrequency( Duration.ONE_SECOND) to my application init() method, the application fails to load pages. It has something to do with the fact that App Engine does not support multiple threads. Because of this I had to find a different solution. Instead I decided that when I was in dev mode I would completely remove the MarkupCache. To do that, I needed to create a new cacheless MarkupFactory.
public class CachelessMarkupFactory extends MarkupFactory {
#Override
public IMarkupCache getMarkupCache() {
return null;
}
#Override
public boolean hasMarkupCache()
{
return false;
}
}
Then in the my WebApplication code, I set my new CachlessMarkupFactory as the default MarkupFactory.
#Override
protected void init()
{
super.init();
//in dev mode, disable markup cache
if(isDevelopmentServer())
{
getMarkupSettings().setMarkupFactory(new CachelessMarkupFactory());
}
}
i'm re writing an app with codename one for other devices other android.
On the simulator everything is working fine, iv'e got some buttons that, when pressed, give access to an HTML page, the actual code for this is:
wifi.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ev){
Form form = new Form("WiFi");
Container container = new Container();
WebBrowser wb = new WebBrowser();
container.addComponent(wb);
wb.setURL("jar:///assets/html/wifi.html");
System.out.println("url:"+wb.getURL());
Command backCommand = new Command("Back") {
public void actionPerformed(ActionEvent ev) {
wifi.getComponentForm().showBack();
}};
form.addCommand(backCommand);
form.setBackCommand(backCommand);
form.addComponent(container);
form.show();
}
});
When i first want to getURL() back, the string is empty; then when i want to build for an android device (Galaxy Nexus with Android 4.3) when i tap on the button it returns me nothing but a blank page.
I also tried with an http link like https://www.google.com, on simulator no problem, on device the usual blank page.
Then i tried modifying the position of the html file, putting it in src like for the image file (that works on device), but still nothing.
I've checked the developer guide and every example i could find, and everyone got no problem with this (and on the simulator me neither). Could anyone solve this?
Thank you :)
Place the file in the root of the src directory and point directly at it without the assets hierarchy for it to work properly across platforms.
I am developing J2ME application with lwuit and Codenameone and created it in lots of time. After I created it I wanted to deploy it in some devices like Nokia, Samsung, LG and etc. that they supported MIDP. So I figure out Nokia devices run it with no error and Samsung and other companies devices have some problems that I can't understand why?!
So I tried different way of creating this application. I used Codenameone wizard with blank theme and manual template and then I tried to deploy it. Well, that right. I got success and it ran in Samsung devices too.
After that I tried to add some forms to "theme" in this appliaction and run it in simulator. I changed some code in my main class like this:
public class Main extends UIBuilder {
private Form current;
public void init(Object context) {
try{
Resources theme = Resources.openLayered("/theme");
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
}catch(IOException e){
e.printStackTrace();
}
}
public void start() {
if(current != null){
current.show();
return;
}
Form hi = findMain();//new Form("Hi World");
//hi.addComponent(new Label("Hi World"));
hi.show();
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
public com.codename1.ui.Form findMain() {
return (com.codename1.ui.Form)findByName("Main", Display.getInstance().getCurrent());
}}
I got error when I ran it.
So this is my questions:
I created one application in Visual Mode of Codenameone.
How can I run it in Samsung and some other devices like Samsung (without opertaing system, just support java or MIDP)?
How can I change my Visual Mode application to Manual Mode in Codenameone?
Thanks in advance.
You are deriving from UIBuilder within the lifecycle class and trying to use a finder method on something that isn't showing yet. There is absolutely no way that your code works in the simulator and it is not the code that was generated by the wizard.
Thanks Shai. For creating I did hard coding and create all of forms one by one.
I implement base Form that derive from com.codenameone.ui.Form and every forms derive from base Form.