Search code examples
androidclingandroid-cling

How to build Cling Android example with Eclipse


I've looked at source code at here https://github.com/4thline/cling/tree/master/demo/android (actually I used the source code that came with Cling 2.0.1 distribution, it's the same)

But after weeks try to build it with my Eclipse, I have no success

I found an article about this here http://datababel.wordpress.com/2013/07/29/upnp-client-in-android-with-cling-getting-started/ but the instruction is still not clear enough.

I want to use Maven with Eclipse to simplify the work have to be done, but in that article, it seems they didn't use Maven but the jetty jar directly

Can someone please give me a step by step how to build the Android source code with Eclipse using Maven (the pom.xml file that came with source code)? I mean something like:

1. Create android project
2. Convert to maven
3. Add something to pom.xml and everything works
4. etc.....something like that

I tried to ask on mailing list of cling forum, but the forum is so inactive, and the forum's owner Chris Bauer is not willing to answer something related to this

Thank you very much. Any help is appreciated.

EDIT 1:

I've tried the solution: Open the .jar file and delete about.html in each .jar, then compress them again. I included 8 jetty .jar file in my project according to this article http://www.gubatron.com/blog/2013/03/12/jar-dependencies-if-you-plan-to-use-the-cling-upnp-library-in-your-android-project/

jetty-security-8.1.8.v20121106.jar
jetty-http-8.1.8.v20121106.jar
jetty-continuation-8.1.8.v20121106.jar
jetty-io-8.1.8.v20121106.jar
jetty-util-8.1.8.v20121106.jar
jetty-server-8.1.8.v20121106.jar
jetty-servlet-8.1.8.v20121106.jar
jetty-client-8.1.8.v20121106.jar

And this is the error log when I run in Eclipse

[2014-12-07 12:07:20 - GR2] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name (org/eclipse/jetty/http/AbstractGenerator) does not match path (org.eclipse.jetty.http_8.1.8.v20121106/org/eclipse/jetty/http/AbstractGenerator.class)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.processClass(Main.java:665)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
    at com.android.dx.command.dexer.Main.access$600(Main.java:78)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:596)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:188)
    at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:786)
    at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:328)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:403)
    at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
    at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
    at org.eclipse.core.internal.resources.Project.build(Project.java:124)
    at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
    at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
...while parsing org.eclipse.jetty.http_8.1.8.v20121106/org/eclipse/jetty/http/AbstractGenerator.class

[2014-12-07 12:07:20 - GR2] Dx 1 error; aborting
[2014-12-07 12:07:20 - GR2] Conversion to Dalvik format failed with error 1

Solution

  • I also encountered a similar problem like this while building the project. You need to make the jar from the directory you extracted it's contents into and not it's parent directory. Basically step 7 of this article - https://datababel.wordpress.com/2013/07/29/upnp-client-in-android-with-cling-getting-started/ needs to be performed from the same directory as "jetty-server\8.1.8.android" directory used in step 4-6.