0

I recently got my JavaFX program to run on android without crashing, but it doesn't currently do anything. Here's a pastebin of the logcat output when the app is first opened (embedding it would get the question flagged as spam).

For reference the line 25492 25518 D GraalCompiled: Error! Icon file does not exist (Trying to read from 'com/testproject/res/icon')! comes from the the code:

try {
InputStream is = Subspecies.class.getClassLoader().getResourceAsStream("com/testproject/res/icon.svg");
            if(is==null) {
                System.err.println("Error! Statistics icon file does not exist (Trying to read from 'com/testproject/res/statistics/health_icon')!");
            }
            healthString = Util.inputStreamToString(is);
            healthString = SvgUtil.colourReplacement("HEALTH", PresetColour.BASE_PINK, healthString);
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

It feels like the issue is somehow related to an issue with permissions, but I have no idea how something like this could have happened. It also could have to do with the fact that the program wasn't originally written to be compiled to Android.

Thanks in advance for any help, and I'm sorry if I'm missing something obvious; it's taken a few weeks to get this thing to even be able to run without crashing and I'm almost out of patience.

  • You have a NPE at `at com.testproject.game.character.statistics.AbstractStatistic.(AbstractStatistic.java:57)`, so you should fix this. The good thing is you can do it on desktop before trying Android. Then if you are unsure about the icon, just comment it out and see if that works, then see why it fails. In any case, SVG files are not directly supported on JavaFX. – José Pereda Jul 04 '23 at 07:51
  • Thanks for the help! I should have been more clear in the question, but the included InputStream is in a try catch, so I doubt that's the issue. Edited it now. – G3XU4L INTERCOURSE Jul 04 '23 at 17:52
  • A try-catch is not going to prevent the failure: GraalVM fails to find the icon nonetheless. So you can comment that block out to test if the rest works, and only then, add it back and fix it: SVG are _not_ supported, and `.svg` extensions need to be in the [resoucesList](https://docs.gluonhq.com/#_resourceslist). Also, build and run the native image on desktop first, it is much more easier to fix issues and then deploy to Android. – José Pereda Jul 04 '23 at 18:09
  • I'm not sure what you mean by build/run on desktop. It runs perfectly with gluonfx:run, and the svg issue is with Graal which is only necessary for Android. Also, I tried commenting that block out, but there were about a dozen others like it that give the same error. Commenting them all out causes the program to not even be able to build. – G3XU4L INTERCOURSE Jul 04 '23 at 23:04
  • Does `mvn gluonfx:build gluonfx:run` works on desktop too? – José Pereda Jul 05 '23 at 07:34
  • Yes, it works perfectly. The issue is exclusively with deploying to Android. – G3XU4L INTERCOURSE Jul 06 '23 at 01:33

0 Answers0