Search code examples
androidupnp

Error when running cling 2.0 Browser example in Android


I am trying to use Cling 2.0 on Android 4.1 and up to be a upnp renderer and server. I get the following error when the the Browser example runs:

Process: com.mike.cling_test, PID: 8846
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/eclipse/jetty/server/Server;
at org.fourthline.cling.transport.impl.jetty.JettyServletContainer.resetServer(JettyServletContainer.java:165)
at org.fourthline.cling.transport.impl.jetty.JettyServletContainer.<init>(JettyServletContainer.java:57)
            at org.fourthline.cling.transport.impl.jetty.JettyServletContainer.<clinit>(JettyServletContainer.java:55)

I have googled the error and I found Cling User forum

I have followed the steps outlined in the the answer, but i still get the same error. The online manual does not seem to be the one I should be using. Is there a pdf of the version 2.0 manual?


Solution

  • i had the same issue, the problem is cling is provided without jetty library.

    You have to use maven dependency like this:

            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-server</artifactId>
                <version>${jetty.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-servlet</artifactId>
                <version>${jetty.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-client</artifactId>
                <version>${jetty.version}</version>
            </dependency>
    

    Or if, like me, you use Android studio, update your gradle script:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.2.1'
        compile files('src/libs/cling-core-2.0.1.jar')
        compile files('src/libs/cling-support-2.0.1.jar')
        compile files('src/libs/seamless-http-1.1.0.jar')
        compile files('src/libs/seamless-util-1.1.0.jar')
        compile files('src/libs/seamless-xml-1.1.0.jar')
        compile 'org.eclipse.jetty:jetty-servlet:8.1.8.v20121106'
        compile 'org.eclipse.jetty:jetty-client:8.1.8.v20121106'
        compile 'org.eclipse.jetty:jetty-server:8.1.8.v20121106'    
    }
    

    Hope that help.