Migrating from Cling 1.0.5 to Cling 2.0 for Android

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Migrating from Cling 1.0.5 to Cling 2.0 for Android

Yash
Hi,
I am using Cling for UPNP , I used  Cling 1.0.5 earlier , but now I am migrating to Cling 2.0 . I used Cling 2.0 from here http://4thline.org/projects/download/cling-distribution-2.0-alpha2.zip .

When i include the jar file (cling-core-2.0-alpha2.jar) in my project ,my application fails with the error :
 java.lang.NoClassDefFoundError: org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl$1

What should I do to resolve errors ?

Thanks...
 
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Cling 1.0.5 to Cling 2.0 for Android

Christian Bauer
Administrator
RTFM
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Cling 1.0.5 to Cling 2.0 for Android

d63hbz@gmail.com
In reply to this post by Yash
I got the same Error, and it seemed unfixable, I hope some one would give an answer.

When I put :
android-support-v4.jar
cling-core-2.0-alpha2.jar
seamless-http-1.0-alpha2.jar
seamless-util-1.0-alpha2.jar
seamless-xml-1.0-alpha2.jar
in my libs folder of Android project, I got:

FATAL EXCEPTION: main
04-02 16:49:26.992: E/AndroidRuntime(23677): java.lang.ExceptionInInitializerError
04-02 16:49:26.992: E/AndroidRuntime(23677): at org.fourthline.cling.android.AndroidUpnpServiceConfiguration.createStreamServer(AndroidUpnpServiceConfiguration.java:110)
04-02 16:49:26.992: E/AndroidRuntime(23677): at org.fourthline.cling.transport.RouterImpl.startAddressBasedTransports(RouterImpl.java:427)
*************blabla********************
04-02 16:49:26.992: E/AndroidRuntime(23677): Caused by: java.lang.NoClassDefFoundError: org.eclipse.jetty.server.Server
04-02 16:49:26.992: E/AndroidRuntime(23677): at org.fourthline.cling.transport.impl.jetty.JettyServletContainer.resetServer(JettyServletContainer.java:132)
04-02 16:49:26.992: E/AndroidRuntime(23677): at org.fourthline.cling.transport.impl.jetty.JettyServletContainer.<init>(JettyServletContainer.java:56)
04-02 16:49:26.992: E/AndroidRuntime(23677): at org.fourthline.cling.transport.impl.jetty.JettyServletContainer.<clinit>(JettyServletContainer.java:54)
04-02 16:49:26.992: E/AndroidRuntime(23677): ... 18 more

When I put :
 cdi-api-1.0-SP1.jar
 cling-core-2.0-alpha2.jar
 httpclient-4.2.3.jar
 httpcore-4.2.3.jar
 jetty-client-9.0.0.v20130308.jar
 jetty-server-9.0.0.v20130308.jar
 jetty-servlet-9.0.0.v20130308.jar
 kxml2-2.3.0.jar
 seamless-http-1.0-alpha2.jar
 seamless-util-1.0-alpha2.jar
 seamless-xml-1.0-alpha2.jar
in my libs folder of Android project, I got the same error.

Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Cling 1.0.5 to Cling 2.0 for Android

iank
In reply to this post by Yash
Did anyone solve this or have extra checks that I can try ?

I am trying to bring up a basic project using the alpha2. I have set my Android Project to API 15, I have included all the right dependencies - including removing the about.html from jetty jars, but I still get this error :-

06-08 23:10:37.402: E/dalvikvm(19646): Could not find class 'org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl$2', referenced from method org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getBindAddresses

I have opened the cling-core jar and can see the class for org.fourthline.cling.transport.impl.NetworkAddressFactoryImp

I have also read the Manual and tried to self-solve this using both an emulator and a real platform

Thanks all
Ian
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Cling 1.0.5 to Cling 2.0 for Android

iank
I think I found the solution, which to be fair is as per the documentation, when you know what your doing... I am trying to pick up Cling so have documented below what I did to resolve this issue.

Note - The Manual available thru the Source code download (and not the public WebPage)
    cling-distribution-2.0-alpha2/core/manual/cling-core-manual.xhtml

(1) As per the docs, See the explanation is 6.6. Configuring network transports

(2) Add (in my case) the class
    public class MyUpnpServiceConfiguration extends DefaultUpnpServiceConfiguration {..... exactly as documented in the Manual

note I had to change getSyncProtocolExecutor() to getSyncProtocolExecutorService to resolve method

(3) In your BrowserUpnpService return MyUpnpServiceConfiguration

e.g.

public class BrowserUpnpService extends AndroidUpnpServiceImpl{

    //@Override
    protected UpnpServiceConfiguration createConfiguration() {
        //return new AndroidUpnpServiceConfiguration() {
    return new MyUpnpServiceConfiguration() {

            // DOC:REGISTRY
            @Override
            public int getRegistryMaintenanceIntervalMillis() {
                return 7000;
            }

(4) In your main Activity .. OnCreate... Change

From
// This will start the UPnP service if it wasn't already started
        getApplicationContext().bindService(
            new Intent(this, AndroidUpnpServiceImpl.class),
            serviceConnection,
            Context.BIND_AUTO_CREATE
        );

To

// This will start the UPnP service if it wasn't already started
        getApplicationContext().bindService(
            new Intent(this, BrowserUpnpService.class),
            serviceConnection,
            Context.BIND_AUTO_CREATE
        );

I seem to be up and running now, but time will tell
Reply | Threaded
Open this post in threaded view
|

Re: Migrating from Cling 1.0.5 to Cling 2.0 for Android

iank
OK - I still got problems...... Here is logcat ?? Any Ideas welcome ?

/UpnpServiceImpl(21117): >>> Starting UPnP service...
I/UpnpServiceImpl(21117): Using configuration: com.example.clingcp1.BrowserUpnpService$1
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/model/message/UpnpHeaders; (2004)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/model/message/UpnpHeaders;' failed
W/dalvikvm(21117): VFY: unable to find class referenced in signature (Lorg/fourthline/cling/model/message/UpnpHeaders;)
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/model/message/UpnpHeaders; (2004)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/model/message/UpnpHeaders;' failed
I/dalvikvm(21117): Could not find method org.fourthline.cling.model.message.UpnpHeaders.getFirstHeader, referenced from method org.fourthline.cling.protocol.ProtocolFactoryImpl.isByeBye
W/dalvikvm(21117): VFY: unable to resolve virtual method 7774: Lorg/fourthline/cling/model/message/UpnpHeaders;.getFirstHeader (Ljava/lang/String;)Ljava/lang/String;
D/dalvikvm(21117): VFY: replacing opcode 0x6e at 0x000a
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/model/message/UpnpHeaders; (2004)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/model/message/UpnpHeaders;' failed
W/dalvikvm(21117): VFY: unable to find class referenced in signature (Lorg/fourthline/cling/model/message/UpnpHeaders;)
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/model/message/UpnpHeaders; (2004)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/model/message/UpnpHeaders;' failed
I/dalvikvm(21117): Could not find method org.fourthline.cling.model.message.UpnpHeaders.getFirstHeader, referenced from method org.fourthline.cling.protocol.ProtocolFactoryImpl.isSupportedServiceAdvertisement
W/dalvikvm(21117): VFY: unable to resolve virtual method 7774: Lorg/fourthline/cling/model/message/UpnpHeaders;.getFirstHeader (Ljava/lang/String;)Ljava/lang/String;
D/dalvikvm(21117): VFY: replacing opcode 0x6e at 0x0020
I/dalvikvm(21117): Could not find method org.seamless.util.Exceptions.unwrap, referenced from method org.fourthline.cling.android.AndroidRouter.handleRouterExceptionOnNetworkTypeChange
W/dalvikvm(21117): VFY: unable to resolve static method 12506: Lorg/seamless/util/Exceptions;.unwrap (Ljava/lang/Throwable;)Ljava/lang/Throwable;
D/dalvikvm(21117): VFY: replacing opcode 0x71 at 0x0000
I/dalvikvm(21117): Could not find method org.seamless.util.Exceptions.unwrap, referenced from method org.fourthline.cling.transport.RouterImpl.handleStartFailure
W/dalvikvm(21117): VFY: unable to resolve static method 12506: Lorg/seamless/util/Exceptions;.unwrap (Ljava/lang/Throwable;)Ljava/lang/Throwable;
D/dalvikvm(21117): VFY: replacing opcode 0x71 at 0x0031
I/dalvikvm(21117): Could not find method org.seamless.util.Exceptions.unwrap, referenced from method org.fourthline.cling.transport.RouterImpl.received
W/dalvikvm(21117): VFY: unable to resolve static method 12506: Lorg/seamless/util/Exceptions;.unwrap (Ljava/lang/Throwable;)Ljava/lang/Throwable;
D/dalvikvm(21117): VFY: replacing opcode 0x71 at 0x0058
I/dalvikvm(21117): Could not find method org.seamless.util.Exceptions.unwrap, referenced from method org.fourthline.cling.transport.RouterImpl.startAddressBasedTransports
W/dalvikvm(21117): VFY: unable to resolve static method 12506: Lorg/seamless/util/Exceptions;.unwrap (Ljava/lang/Throwable;)Ljava/lang/Throwable;
D/dalvikvm(21117): VFY: replacing opcode 0x71 at 0x0081
I/Router  (21117): Creating Router: org.fourthline.cling.android.AndroidRouter
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$2; (2025)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$2;' failed
E/dalvikvm(21117): Could not find class 'org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl$2', referenced from method org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getBindAddresses
W/dalvikvm(21117): VFY: unable to resolve new-instance 1948 (Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$2;) in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;
D/dalvikvm(21117): VFY: replacing opcode 0x22 at 0x0000
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$1; (2025)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$1;' failed
E/dalvikvm(21117): Could not find class 'org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl$1', referenced from method org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getNetworkInterfaces
W/dalvikvm(21117): VFY: unable to resolve new-instance 1947 (Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$1;) in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;
D/dalvikvm(21117): VFY: replacing opcode 0x22 at 0x0000
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$2; (2025)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$2;' failed
D/dalvikvm(21117): DexOpt: unable to opt direct call 0x2f3e at 0x04 in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;.getBindAddresses
W/dalvikvm(21117): Unable to resolve superclass of Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$1; (2025)
W/dalvikvm(21117): Link of class 'Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl$1;' failed
D/dalvikvm(21117): DexOpt: unable to opt direct call 0x2f3c at 0x04 in Lorg/fourthline/cling/transport/impl/NetworkAddressFactoryImpl;.getNetworkInterfaces
D/AndroidRuntime(21117): Shutting down VM
W/dalvikvm(21117): threadid=1: thread exiting with uncaught exception (group=0x40acc300)
E/AndroidRuntime(21117): FATAL EXCEPTION: main
E/AndroidRuntime(21117): java.lang.NoClassDefFoundError: org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl$1
E/AndroidRuntime(21117): at org.fourthline.cling.transport.impl.NetworkAddressFactoryImpl.getNetworkInterfaces(NetworkAddressFactoryImpl.java:145)
E/AndroidRuntime(21117): at org.fourthline.cling.transport.RouterImpl.enable(RouterImpl.java:131)
E/AndroidRuntime(21117): at org.fourthline.cling.android.AndroidRouter.enable(AndroidRouter.java:88)
E/AndroidRuntime(21117): at org.fourthline.cling.UpnpServiceImpl.<init>(UpnpServiceImpl.java:87)
E/AndroidRuntime(21117): at org.fourthline.cling.android.AndroidUpnpServiceImpl$1.<init>(AndroidUpnpServiceImpl.java:54)
E/AndroidRuntime(21117): at org.fourthline.cling.android.AndroidUpnpServiceImpl.onCreate(AndroidUpnpServiceImpl.java:54)
E/AndroidRuntime(21117): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2363)
E/AndroidRuntime(21117): at android.app.ActivityThread.access$1600(ActivityThread.java:130)
E/AndroidRuntime(21117): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1290)
E/AndroidRuntime(21117): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(21117): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(21117): at android.app.ActivityThread.main(ActivityThread.java:4748)
E/AndroidRuntime(21117): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(21117): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(21117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
E/AndroidRuntime(21117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
E/AndroidRuntime(21117): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  478):   Force finishing activity com.example.clingcp1/.ControlPoint