purejava / appindicator-gtk3-java

Java bindings for appindicator
MIT License
10 stars 0 forks source link

unresolved symbol: app_indicator_new on Fedora #68

Closed sblantipodi closed 3 weeks ago

sblantipodi commented 3 weeks ago

Please agree to the following

Summary

Simple code sample on the wiki throws an exception.

What software is involved?

Fedora 41

libayatana-appindicator-gtk2      0.5.93-6.fc41                                                                     
 libayatana-appindicator-gtk3     0.5.93-6.fc41                                                                     

OpenJDK 23

Classifier

libappindicator-full

Steps to Reproduce

I added this code to my Java FX app.

public void initTray() {
        try (var arena = Arena.ofConfined()) {
            var arenaAuto = Arena.ofAuto();
            var indicator = AppIndicator.newIndicator("example-simple-client",
                    "indicator-message",
                    APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
            var gtkSeparator = Gtk.newMenuItem();
            var gtkMenu = Gtk.newMenu();
            var gtkSubmenu = Gtk.newMenu();
            var gtkMenuItem = Gtk.newMenuItem();
            Gtk.menuItemSetLabel(gtkMenuItem, "More");
            var gtkSMenuItem = Gtk.newMenuItem();
            Gtk.menuItemSetLabel(gtkSMenuItem, "Change icon");
            var gtkSMenuItem1 = Gtk.newMenuItem();
            Gtk.menuItemSetLabel(gtkSMenuItem1, "Quit");
            Gtk.menuShellAppend(gtkSubmenu, gtkSMenuItem);
            Gtk.menuShellAppend(gtkSubmenu, gtkSeparator);
            Gtk.menuShellAppend(gtkSubmenu, gtkSMenuItem1);
            Gtk.menuItemSetSubmenu(gtkMenuItem, gtkSubmenu);
//            GObject.signalConnectObject(gtkSMenuItem1, "activate", GCallback.allocate(new QuitCallback(), arenaAuto), gtkMenu, 0);
//            GObject.signalConnectObject(gtkSMenuItem, "activate", GCallback.allocate(new ChangeIconCallback(indicator), arenaAuto), gtkMenu, 0);
            Gtk.menuShellAppend(gtkMenu, gtkMenuItem);
            Gtk.widgetShowAll(gtkMenu);
            AppIndicator.setMenu(indicator, gtkMenu);
            AppIndicator.setAttentionIcon(indicator, "indicator-messages-new");
            AppIndicator.setStatus(indicator, APP_INDICATOR_STATUS_ACTIVE());
        }
}

Expected Behavior

tray icon working

Actual Behavior

exception is thrown

Reproducibility

Always

Relevant Log Output

Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
    at javafx.graphics@23/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
    at javafx.graphics@23/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: java.lang.UnsatisfiedLinkError: unresolved symbol: app_indicator_new
    at org.purejava.appindicator@1.4.1/org.purejava.appindicator.app_indicator_h_21.lambda$findOrThrow$0(app_indicator_h_21.java:33)
    at java.base/java.util.Optional.orElseThrow(Optional.java:403)
    at org.purejava.appindicator@1.4.1/org.purejava.appindicator.app_indicator_h_21.findOrThrow(app_indicator_h_21.java:33)
    at org.purejava.appindicator@1.4.1/org.purejava.appindicator.app_indicator_h_1$app_indicator_new.<clinit>(app_indicator_h_1.java:1467)
    at org.purejava.appindicator@1.4.1/org.purejava.appindicator.app_indicator_h_1.app_indicator_new(app_indicator_h_1.java:1496)
    at org.purejava.appindicator@1.4.1/org.purejava.appindicator.AppIndicator.newIndicator(AppIndicator.java:81)
    at org.dpsoftware/org.dpsoftware.gui.TrayIconManager.initTray(TrayIconManager.java:242)
    at org.dpsoftware/org.dpsoftware.FireflyLuciferin.start(FireflyLuciferin.java:261)
    at javafx.graphics@23/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
    at javafx.graphics@23/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
    at javafx.graphics@23/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at javafx.graphics@23/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
    at javafx.graphics@23/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at javafx.graphics@23/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics@23/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:264)
    ... 1 more

Anything else?

am I doing something wrong?

purejava commented 3 weeks ago

Hi @sblantipodi,

thanks for bringing this up. No, you are not doing anything wrong. It is unable to load the libayatana-appindicator-gtk3 shared library, although you have it installed. That leads to the java.lang.UnsatisfiedLinkError you see.

I looked into this and noticed, that Fedora has a different layout to store its 64bit libraries. They are located in /usr/lib64, not in /usr/lib or a path mentioned in /etc/ld.so.conf.d/, like other distributions like Arch Linux or the Debian family handle this.

I need to fix this in these Java bindings by adding /usr/lib64 to the library search path on library loading and create a new release of the bindings containing the fix.

As a workaround, you might consider to symlink the installed library like ln -s /usr/lib64/libayatana-appindicator3.so.1 /usr/lib/.

purejava commented 3 weeks ago

Fixed with 6dbc6a4cdcff90ed7afae002b4328c7d086ec4bb, 224a4e5a8d7c267936c243dc73afba899e1a45ae and 8ddc2e5768591ffd7da7971423fe9f85c42f9ff6 and fixes released as Release 1.4.2.