JavaOSC icon indicating copy to clipboard operation
JavaOSC copied to clipboard

Cannot receive OSC on android API 32

Open lillithrosepup opened this issue 1 year ago • 7 comments

java.lang.NoSuchMethodError: No virtual method getDefinedPackage(Ljava/lang/String;)Ljava/lang/Package; in class Ljava/lang/ClassLoader; or its super classes (declaration of 'java.lang.ClassLoader' appears in /apex/com.android.art/javalib/core-oj.jar)
                                                                                                    	at com.illposed.osc.LibraryInfo.<clinit>(LibraryInfo.java:46)
                                                                                                    	at com.illposed.osc.LibraryInfo.hasStandardProtocolFamily(LibraryInfo.java:283)
                                                                                                    	at com.illposed.osc.transport.udp.UDPTransport.<init>(UDPTransport.java:61)
                                                                                                    	at com.illposed.osc.transport.OSCPort.<init>(OSCPort.java:40)
                                                                                                    	at com.illposed.osc.transport.OSCPortIn.<init>(OSCPortIn.java:108)
                                                                                                    	at com.illposed.osc.transport.OSCPortIn.<init>(OSCPortIn.java:123)
                                                                                                    	at com.illposed.osc.transport.OSCPortIn.<init>(OSCPortIn.java:132)
                                                                                                    	at com.illposed.osc.transport.OSCPortIn.<init>(OSCPortIn.java:145)
                                                                                                    	at com.illposed.osc.transport.OSCPortIn.<init>(OSCPortIn.java:160)
                                                                                                    	at com.illposed.osc.transport.OSCPortIn.<init>(OSCPortIn.java:170)```


here is the code it is running in: ```kt
package gay.lilyy.lilypad.core.osc

import com.illposed.osc.MessageSelector
import com.illposed.osc.OSCMessageEvent
import com.illposed.osc.OSCMessageListener
import com.illposed.osc.transport.OSCPortIn
import gay.lilyy.lilypad.core.modules.CoreModules
import gay.lilyy.lilypad.core.modules.Modules
import io.github.aakira.napier.Napier

object OSCReceiver {
    var receiver: OSCPortIn? = null

    val listeners: MutableList<Pair<MessageSelector, OSCMessageListener>> = mutableListOf()
    fun updateAddress() {
        if (CoreModules.Core.config!!.logs.debug) Napier.d("Updating OSC receiver address to ${CoreModules.Core.config!!.listen}")
        receiver?.close()
        receiver = OSCPortIn(CoreModules.Core.config!!.listen)
        for ((selector, listener) in listeners) {
            receiver?.dispatcher?.addListener(selector, listener)
        }
        receiver?.startListening()
    }

    init {
        updateAddress()
        addListener({ true }) {
            if (CoreModules.Core.config!!.logs.incomingData) Napier.d("Received message: ${it.message.address} ${it.message.arguments.joinToString()}")
        }
    }


    fun addListener(matches: (OSCMessageEvent) -> Boolean, listener: OSCMessageListener) {
        val selector = object : MessageSelector {
            override fun isInfoRequired(): Boolean = false

            override fun matches(event: OSCMessageEvent): Boolean {
                return matches(event)
            }
        }
        listeners += selector to listener
        receiver?.dispatcher?.addListener(selector, listener)
    }
}

i am attempting to run this on a Meta Quest 3

lillithrosepup avatar Sep 20 '24 19:09 lillithrosepup

temporary fix is downgrading to 0.8, as the problem code was introduced in https://github.com/hoijui/JavaOSC/commit/2cbbc433a354fc0ba326b44826e1ae2b0a7f8350

lillithrosepup avatar Sep 20 '24 19:09 lillithrosepup

@ImLvna I'm searching for an Android sample to receive messages, do you have one ?

hannesa2 avatar Sep 23 '24 15:09 hannesa2

Hey there! The project i am using this in is ImLvna/Lilypad. To recreate it, bump osc in the versions category of ./gradle/libs.versions.toml back up to 0.9, and possibly remove the backported java.awt.color fix from here found in ./lilypadApp/src/commonMain/kotlin/gay/lilyy/lilypad/core/osc/OSCSender.kt

edit: ohh, i misunderstood. if you are just trying to recieve messages and not looking to fix the bug, you don't need to make any changes to my code. you will need to use javaosc 0.8 as 0.9 is broken on android, and for sending messages you will need to use this fix for avoiding java.awt.color. feel free to take my code. It is unlicensed as i have not set that up yet, but do whatever you need with it

lillithrosepup avatar Sep 25 '24 13:09 lillithrosepup

It would be nice if someone developing on Android could fix this. I don't and I won't setup Android dev stuff.

hoijui avatar Dec 30 '24 18:12 hoijui

@hoijui @lillithkt it looks like you forked this project in ImLvna/Lilypad and fixed it there. Is there any way you could commit your fix to this project as well? It seems there are a number of people facing the same issues trying to run on Android.

cormacstewart14 avatar Feb 17 '25 15:02 cormacstewart14

@cormacstewart14 There all my pull request where closed unmerged. That guy wants to solve it by himself, that's why I see it as a waste of time to continue there.

Image

hannesa2 avatar Feb 17 '25 15:02 hannesa2

@hannesa2 that is too bad. This project would be a huge help for us.

cormacstewart14 avatar Feb 17 '25 16:02 cormacstewart14